Dovecot + Postfix can send but email will not show up in inbox

T. Zack Crawford asked:

I am trying to set up an email server on my personal website server. I am mostly there, I can send email but sending emails to the address I am setting up does not appear to be populating the cur or new directories in the Inbox or Junk directories with new files. Although Sent does populate after sending an email (this seems to always work successfully).

The daemons for the relevant packages are active and don’t seem to have any warnings/errors.
MX records etc seem okay and DKIM test says everything is fine, plus I am not on any spam lists.
At this point, I am basically lost.

I am using Arch Linux on a personal server with the following package versions:

postfix 3.5.6-1
dovecot 2.3.10.1-2
opendkim 2.10.3-7
pigeonhole 0.5.10-2
procmail 3.22-10
spamassassin 3.4.4-3

Here is a segment of the system journal (I don’t think postfix is allowed its own log?). It’s the only part that seemed to have valuable information, although I don’t understand it. Some sort of milter issue? (Also I have replaced personal identification e.g. IPs and domain name)

Aug 05 13:01:29 user postfix/cleanup[94749]: 836A924F0B: message-id=<[email protected]>
Aug 05 13:01:29 user postfix/qmgr[94666]: 836A924F0B: from=<[email protected]>, size=499, nrcpt=1 (queue active)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: public/cleanup socket: wanted attribute: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute value: 0
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: public/cleanup socket: wanted attribute: reason
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: reason
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute value: (end)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: public/cleanup socket: wanted attribute: (list terminator)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: (end)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: > unknown[666.666.666.666]: 250 2.0.0 Ok: queued as 836A924F0B
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: abort all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: milter8_abort: abort milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: < unknown[666.666.666.666]: QUIT
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: > unknown[666.666.666.666]: 221 2.0.0 Bye
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostname: smtpd_client_event_limit_exceptions: unknown ~? 127.0.0.1/32Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostaddr: smtpd_client_event_limit_exceptions: 666.666.666.666 ~? 127.0.0.1/32
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostname: smtpd_client_event_limit_exceptions: unknown ~? 777.777.777.777/32
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostaddr: smtpd_client_event_limit_exceptions: 666.666.666.666 ~? 777.777.777.777/32
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_list_match: unknown: no match
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_list_match: 666.666.666.666: no match
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: send attr request = disconnect
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: send attr ident = submission666.666.666.666:
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: private/anvil: wanted attribute: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute value: 0
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: private/anvil: wanted attribute: (list terminator)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: (end)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: abort all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: milter8_abort: abort milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: disconnect event to all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: milter8_disc_event: quit milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: disconnect from unknown[666.666.666.666] ehlo=2 starttls=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=8
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: free all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: free milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: master_notify: status 1
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: connection closed
Aug 05 13:01:29 user postfix/smtp[94750]: 836A924F0B: to=<[email protected]>, relay=none, delay=0.38, delays=0.21/0.06/0.11/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
Aug 05 13:01:30 user postfix/cleanup[94749]: 00DA924F0E: message-id=<[email protected]>
Aug 05 13:01:30 user postfix/bounce[94751]: 836A924F0B: sender non-delivery notification: 00DA924F0E
Aug 05 13:01:30 user postfix/qmgr[94666]: 00DA924F0E: from=<>, size=2965, nrcpt=1 (queue active)
Aug 05 13:01:30 user postfix/qmgr[94666]: 836A924F0B: removed
Aug 05 13:01:30 user postfix/smtp[94750]: 00DA924F0E: to=<[email protected]>, relay=none, delay=0.06, delays=0.02/0/0.04/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
Aug 05 13:01:30 user postfix/qmgr[94666]: 00DA924F0E: removed

I have opened the necessary ports and verified. Online port check tools confirm.
here (v6)

Port listening seems to be working as expected. Here is a segment of lsof -iTCP -sTCP:LISTEN -P

COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
dovecot   92963     root   21u  IPv4 963311      0t0  TCP *:110 (LISTEN)
dovecot   92963     root   22u  IPv6 963312      0t0  TCP *:110 (LISTEN)
dovecot   92963     root   23u  IPv4 963313      0t0  TCP *:995 (LISTEN)
dovecot   92963     root   24u  IPv6 963314      0t0  TCP *:995 (LISTEN)
dovecot   92963     root   39u  IPv4 963359      0t0  TCP *:143 (LISTEN)
dovecot   92963     root   40u  IPv6 963360      0t0  TCP *:143 (LISTEN)
dovecot   92963     root   41u  IPv4 963361      0t0  TCP *:993 (LISTEN)
dovecot   92963     root   42u  IPv6 963362      0t0  TCP *:993 (LISTEN)
master    93066     root   88u  IPv4 964097      0t0  TCP *:25 (LISTEN)
master    93066     root   91u  IPv4 964100      0t0  TCP *:587 (LISTEN)
master    93066     root   94u  IPv4 964103      0t0  TCP *:465 (LISTEN)
opendkim  93089 opendkim    3u  IPv4 964461      0t0  TCP localhost:12301 (LISTEN)
spamd     93121     root    6u  IPv6 964939      0t0  TCP localhost:783 (LISTEN)
spamd     93121     root    7u  IPv4 964941      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93144    spamd    6u  IPv6 964939      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93144    spamd    7u  IPv4 964941      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93145    spamd    6u  IPv6 964939      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93145    spamd    7u  IPv4 964941      0t0  TCP localhost:783 (LISTEN)
smtp      93244  postfix    6u  IPv4 964097      0t0  TCP *:25 (LISTEN)

Here are the contents of postfix main.cf

compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/bin
daemon_directory = /usr/lib/postfix/bin
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps
debug_peer_level = 2
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/bin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = /usr/share/doc/postfix
inet_protocols = ipv4
meta_directory = /etc/postfix
shlib_directory = /usr/lib/postfix
smtpd_tls_key_file = /etc/letsencrypt/live/mail.domain.com/privkey.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.domain.com/fullchain.pem
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
home_mailbox = ~/Mail/Inbox/
#smtpd_milters = inet:localhost:12301 #Can't find localhost? is there some issue with /etc/hosts?
#non_smtpd_milters = inet:localhost:12301
#127.0.0.1 should work anyway I think
smtpd_milters = inet:127.0.0.1:12301
non_smtpd_milters = inet:127.0.0.1:12301
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous
myhostname = mail.domain.com
milter_default_action = accept
milter_protocol = 6

Here are the contents of master.cf

pickup    unix  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
relay     unix  -       -       n       -       -       smtp
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd
smtp unix - - n - - smtp 
smtp inet n - y - - smtp -v
  -o content_filter=spamassassin 
submission inet n       -       y       -       -       smtpd -v
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
submissions     inet  n       -       y       -       -       smtpd -v
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
spamassassin unix -     n       n       -       -       pipe
  user=spamd argv=/usr/bin/vendor_perl/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}" 

Here are the contents of dovecot.conf

ssl = required
ssl_cert = </etc/letsencrypt/live/mail.domain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.domain.com/privkey.pem
ssl_dh = </etc/dovecot/dh.pem

auth_mechanisms = plain login
protocols = $protocols imap
disable_plaintext_auth = no
mail_privileged_group = mail

userdb {
        driver = passwd
}
passdb {
        driver = pam
        args = session=yes failure_show_msg=yes
}


mail_location = maildir:~/Mail:INBOX=~/Mail/Inbox:LAYOUT=fs
namespace inbox {
        inbox = yes
       
        mailbox Drafts {
        special_use = \Drafts
        auto = create
        }

        mailbox Junk {
        special_use = \Junk
        auto = create
        autoexpunge = 30d
        }
        
        mailbox Sent {
        special_use = \Sent
        auto = create
        }

        mailbox Trash {
        special_use = \Trash
        auto = create
        }

        mailbox Archive {
        special_use = \Archive
        auto = create
        }
        mailbox Done {
        auto = create
        }
}

service auth {
  unix_listener /var/spool/postfix/private/auth {
        mode = 0660
        user = postfix
        group = postfix
    }
}

protocol lda {
  mail_plugins = $mail_plugins sieve
}

protocol lmtp {
  mail_plugins = $mail_plugins sieve
}

plugin {
        sieve = ~/.dovecot.sieve
        sieve_default = /var/lib/dovecot/sieve/default.sieve
        sieve_dir = ~/.sieve
        sieve_global_dir = /var/lib/dovecot/sieve/
}

#Logging
log_path = /var/log/dovecot.log
auth_verbose = yes
mail_debug = yes
auth_debug = yes
auth_debug_passwords = yes
verbose_ssl=yes

Contents of /etc/postfix/aliases

mailer-daemon: postmaster
postmaster: root
root: user 
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root

Contents of /var/lib/dovecot/sieve/default.sieve

require ["fileinto", "mailbox"];
if header :contains "X-Spam-Flag" "YES"
        {
                fileinto "Junk";
        }   

Contents of /etc/opendkim/opendkim.conf

BaseDirectory           /var/lib/opendkim
Domain                  tzcrawford.com
KeyFile                 /etc/opendkim/mail.private
Selector                mail
Socket                  inet:[email protected]
Syslog                  Yes
TemporaryDirectory      /run/opendkim
UMask                   002
Canonicalization        relaxed/simple
KeyTable file:/etc/opendkim/keytable
SigningTable refile:/etc/opendkim/signingtable
InternalHosts refile:/etc/opendkim/trustedhost

Let me know if you have any ideas or want more info, thanks!

My answer:


Postfix has not been configured to accept mail for your domain name, thus when it looks up the domain’s MX record and finds it specifies itself as the mail server to deliver to, it throws the error "mail loops back to myself". Because it doesn’t actually accept mail for your domain, the only thing it can do is bounce the message.

Then we see that the bounce message itself also bounced, for the same reason. What happened then is in subsequent log entries that you did not post, but generally such a message gets dropped or logged somewhere.

You need to configure Postfix to accept mail for your domain name. You can do this with the myorigin= directive in main.cf, which should be set to $mydomain:

myorigin=$mydomain

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.