I want to check the standard output for mail in CentOS, Postfix, and Dovecot.

Asked 1 years ago, Updated 1 years ago, 89 views

I built a mail server using Postfix and Dovecot.
I can send and receive emails without any problems.

I often want to quickly check the contents when connecting with ssh, but I don't know how to open the file correctly.
Mail received is stored in ~/Maildir/new/, but is garbled when opened with the cat command.

How can I check not only my mail, but also when I am a root user and want to check other users' mail?

This may be an elementary question, but I couldn't find it after searching it well, so please let me know.
Thank you for your cooperation.

centos postfix dovecot

2022-09-30 16:18

3 Answers

If it is CentOS 6,7 mailx, I think you can read it in mailx-f~/Maildir.

Is garbled characters due to differences in encoding, or is Base64, Quoted-printable displayed as it is?
In the former case, the charset is set correctly in the mail header, and if the shell environment variable and terminal emulator encoding are combined, I think I could read it by mailx.
(Example) LANG=ja_JP.UTF-8mailx-f~/Maildir


2022-09-30 16:18

Pager with character code conversion function, specifically lv, nkf, iconv, etc.


2022-09-30 16:18

If you are using Dovecot and have root privileges, you may want to search and retrieve it by doveadm (1).

Retrieve all body parts of user alice new mail messages:

#doveadm search-ualice NEW\
  | while read mailbox_guide;do
    doveadm fetch-ualice body mailbox-guid$mailbox_guiduid$uid
  done\
;

See the online documentation doveadm-search (1), doveadm-search-query (7), doveadm-fetch (1).


2022-09-30 16:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.