Score:0

Postfix - can't send emails to gmail addresses via terminal

fo flag
Run

I have the following errors when trying to send emails to gmail addresses via my terminal:

sudo tail /var/log/mail.log
Jul 19 13:19:44 ubuntu-4gb-fsn1-1 postfix/cleanup[5780]: B4B8C5F4A3: message-id=<20230719131944.B4B8C5F4A3@ubuntu-4gb-fsn1-1>
Jul 19 13:19:44 ubuntu-4gb-fsn1-1 postfix/qmgr[4961]: B4B8C5F4A3: from=<[email protected]>, size=269, nrcpt=2 (queue active)
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/smtp[5782]: B4B8C5F4A3: to=<[email protected]>, orig_to=<[email protected]>, relay=gmail-smtp-in.l.google.com[2a00:1450:400c:c00::1a]:25, delay=0.36, delays=0.02/0.02/0.13/0.19, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:400c:c00::1a] said: 550-5.7.1 [2a01:4f8:c012:4b7::1] Our system has detected that this message does 550-5.7.1 not meet IPv6 sending guidelines regarding PTR records and 550-5.7.1 authentication. Please review 550-5.7.1  https://support.google.com/mail/?p=IPv6AuthError for more information 550 5.7.1 . x6-20020adfffc6000000b003141bf7bf82si2173949wrs.938 - gsmtp (in reply to end of DATA command))
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/smtp[5783]: B4B8C5F4A3: to=<[email protected]>, orig_to=<[email protected]>, relay=mx-eu.mail.am0.yahoodns.net[188.125.72.74]:25, delay=0.58, delays=0.02/0.03/0.26/0.27, dsn=2.0.0, status=sent (250 ok dirdel)
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/cleanup[5780]: 4C4165F4A6: message-id=<20230719131945.4C4165F4A6@ubuntu-4gb-fsn1-1>
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/bounce[5784]: B4B8C5F4A3: sender non-delivery notification: 4C4165F4A6
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/qmgr[4961]: 4C4165F4A6: from=<>, size=3040, nrcpt=1 (queue active)
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/qmgr[4961]: B4B8C5F4A3: removed
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/smtp[5782]: 4C4165F4A6: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[64.233.184.26]:25, delay=0.52, delays=0/0/0.11/0.41, dsn=5.7.26, status=bounced (host gmail-smtp-in.l.google.com[64.233.184.26] said: 550-5.7.26 This mail is unauthenticated, which poses a security risk to the 550-5.7.26 sender and Gmail users, and has been blocked. The sender must 550-5.7.26 authenticate with at least one of SPF or DKIM. For this message, 550-5.7.26 DKIM checks did not pass and SPF check for [] did not pass with ip: 550-5.7.26 [128.140.116.155]. The sender should visit 550-5.7.26  https://support.google.com/mail/answer/81126#authentication for 550 5.7.26 instructions on setting up authentication. n18-20020a5d6612000000b003142602c3e3si2110526wru.914 - gsmtp (in reply to end of DATA command))
Jul 19 13:19:45 ubuntu-4gb-fsn1-1 postfix/qmgr[4961]: 4C4165F4A6: removed

I have set my PTR record on ipv6 to:

mail.xxx.net

I have also added both SPF and DKIM to my DNS records. I have set up my website using ipv6 and ipv4 for the mail server.

What else have I missed or misconfigured?

Note I have set my Postfix to forward incoming emails to my yahoo and googlemail accounts. This works ok.

The error above happens only when I try to send emails (gmail to my domain) via my terminal:

echo "test email" | sendmail -F "LXX" -f "[email protected]" [email protected]

No error when send emails from my domain to gmail via my terminal:

echo "test email" | sendmail -F "LXX" -f "[email protected]" [email protected]

Why? Any ideas?

Keith Langmead avatar
us flag
You can have all the SPF and DKIM in the world on your own domain for sending from there, if you're sending FROM Gmail instead it's not going to help. Gmail error is perhaps less clear than it could be, but I imagine they've tailored it to focus on the most likely/common cause of that issue... where people are indeed sending from their own domain, but don't have SPF/DKIM in place on their domain.
Score:1
ws flag

I was surprised to learn that Google still use this. Presumably rather than RMX they just need the PTR to match the SMTP HELO. Does it?

I have set my PTR record on ipv6 to:

I hope you have actually set it to something which conforms to the spec and not what you've shown us here. There are lots of SPF testers on the internet - have you tried one?

The error above happens only when I try to send emails (gmail to my domain) via my terminal:

Ah. That's the problem. If the email is going VIA your MTA then Google thinks you are spamming. Your domain is not a valid origin for gmail. You need to configure your Gmail account to use "Less secure app access", and configure your postfix instance to relay all email via Gmail using your Gmail login and password.

The is a bit easier to setup with nullmailer alternatively just use an email address from your domain as the FROM + from:

Run avatar
fo flag
Run
Thanks for the answer. Will try nullmailer and see it works. I am pretty sure I have set SPF correctly. Done it many times. But never tested with any tester. What are these testers? Link please.
Run avatar
fo flag
Run
I just found this https://www.mail-tester.com/ and tested my DKIM and SPF. It just printed out what I set in my DNS records. No error highlighted by them
ws flag
You still can't send email pretending you're Google. You need to log into Google and relay.
Run avatar
fo flag
Run
you are right. it is not right to send gmail emails from my server.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.