Why doesn't "Postfix sendmail" send email logged in with non-root user?
Environment with Debian 9.9, Apache 2.4, Postfix 3.1 and Let's Encrypt.
1st.case: when the email does not appear in the recipient's inbox.
Sendmail does not send email when logged in as non-root and using "sudo sendmail", eg:
non-root@exemplo:$ sudo sendmail recipient@gmail.com
From:support@exemplo.com.br
Subject: Subject identification
Here I put the body of the sent email
.
non-root@exemplo:$ tail -10 mail.log
Aug 7 20:58:16 exemplo postfix/pickup[26495]: B46097866A: uid=0 from=<root>
Aug 7 20:58:16 exemplo postfix/cleanup[27294]: B46097866A: message-id=20190807235816.B46097866A@cuccohmlg.com.br
Aug 7 20:58:16 exemplo postfix/qmgr[22015]: B46097866A: from=root@cuccohmlg.com.br, size=336, nrcpt=1 (queue active)
Aug 7 20:58:17 exemplo postfix/smtp[27296]: B46097866A: to=recipient@gmail.com, relay=gmail-smtp-in.l.google.com[2607:f8b0:400d:c0b::1b]:25, delay=56, delays=55/0.01/0.15/0.41, dsn=2.0.0, status=sent (250 2.0.0 OK 1565222297 a2si52703387qka.150 - gsmtp)
Aug 7 20:58:17 exemplo postfix/qmgr[22015]: B46097866A: removed</root>
2nd case: The email appears in the recipient's inbox. Sendmail sends email when logged in as root, eg:
root@exemplo: ~# sendmail recipient@gmail.com
From:origin@exemplo.com.br
Subject:Subject identification
Here I put the body of the sent email
.
In these 2 previous cases, why the email does not appear in the recipient@gmail.com inbox for 1st case?
Does anyone have any information how I can solve this problem?
Thank you very much
Antonio
4 Replies
Hi Antonio! It looks like the mail was sent in both cases, but only showed up in the Gmail inbox the time it was sent from the root user, is that correct? If so, it may not be the Linux user that is making a difference, but rather Google's mail filtering algorithms. I'd recommend checking to see if the messages wound up in the 'spam' folder, or if you get different results when replying to an email sent from the Gmail address.
I'm assuming the name in this log entry is your hostname (or at least the one postfix is using during its helo/ehlo):
Aug 7 20:58:16 exemplo postfix/cleanup[27294]: B46097866A: message-id=20190807235816.B46097866A@cuccohmlg.com.br
This log entry shows gmail accepting the mail ('250' here is the receiving server saying 'got it!'):
Aug 7 20:58:17 exemplo postfix/smtp[27296]: B46097866A: to=recipient@gmail.com, relay=gmail-smtp-in.l.google.com[2607:f8b0:400d:c0b::1b]:25, delay=56, delays=55/0.01/0.15/0.41, dsn=2.0.0, status=sent (250 2.0.0 OK 1565222297 a2si52703387qka.150 - gsmtp)
But what is notable is it received it at a google ipv6 address. That means your postfix setup probably sent it via ipv6.
Google can be picky about there being a reverse dns entry (a PTR record) that matches with the hostname that is used by the sending server.
I can see you have a forward record for the cuccohmlg.com.br name for both ipv4 and ipv6:
$ dig +short -t a cuccohmlg.com.br
50.116.62.66$ dig +short -t aaaa cuccohmlg.com.br
2600:3c03::f03c:91ff:fe62:5d1d
But I only see a reverse for the ipv4 address:
$ dig +short -x 50.116.62.66
cuccohmlg.com.br.$ dig +short -x 2600:3c03::f03c:91ff:fe62:5d1d
(no response)
You'll want to either set a reverse for the ipv6 address that matches, or turn off sending via ipv6 in postfix. To make the reverse entry, do it just like you did for ipv4:
https://www.linode.com/docs/networking/dns/configure-your-linode-for-reverse-dns/
If you want to go the route of only having postfix use ipv4, in your postfix main.cf, you'd set
inet_protocols = ipv4
postfix reference