No longer able to send e-mails from Ubuntu server to Gmail group

Phil asked:

I have an issue where sending e-mail from our Ubuntu server to a Google Group account no longer works and results in the Google group rejecting the e-mail. (Please note that when I say Google Groups, I don’t mean, but rather a group set up in my Gmail account console). This used to work and has only recently (in the last 2 weeks) stopped working. Now when mail is attempted to be sent the following error is shown in /var/log/mail.log :

Mar 19 15:36:04 server217-174-255-91 postfix/pickup[11890]: D60AF40066A: uid=33 from=<www-data>
Mar 19 15:36:04 server217-174-255-91 postfix/cleanup[12498]: D60AF40066A: message-id=<>
Mar 19 15:36:04 server217-174-255-91 postfix/qmgr[11968]: D60AF40066A: from=<>, size=439, nrcpt=1 (queue active)
Mar 19 15:36:04 server217-174-255-91 postfix/smtp[12499]: connect to[2a00:1450:400c:c03::1b]:25: Network is unreachable
Mar 19 15:36:05 server217-174-255-91 postfix/smtp[12499]: D60AF40066A: to=<>,[]:25, delay=0.27, delays=0.05/0.01/0.06/0.15, dsn=2.0.0, status=sent (250 2.0.0 OK 1426779365 jf1si3669888wic.51 - gsmtp)
Mar 19 15:36:05 server217-174-255-91 postfix/qmgr[11968]: D60AF40066A: removed
Mar 19 15:36:05 server217-174-255-91 postfix/smtpd[12462]: connect from[]
Mar 19 15:36:05 server217-174-255-91 postfix/smtpd[12462]: NOQUEUE: reject: RCPT from[]: 454 4.7.1 <>: Relay access denied; from=<> to=<> proto=ESMTP helo=<>
Mar 19 15:36:05 server217-174-255-91 postfix/smtpd[12462]: disconnect from[]

The sending of the mail is via PHP and is like the following:

mail("mygroup@ourGmailDomain", "Subject", "Message", "Header");

If I change my PHP to use an individual users account and not a group, then it works and the e-mail is received. So the following code does work and the user “aPerson” receives the e-mail:

mail("aPerson@ourGmailDomain", "Subject", "Message", "Header");

What am I doing wrong? What is special about the group that is causing the e-mails to be rejected whereas sending to an individual Gmail account causes the mail to be accepted?

Update with my findings:

This issue has now been resolved. I believe that the issue was to do with the mail being sent having a bad or invalid header. The mail was being sent by the user www-data but within the header we had added “from: ” and then another user. I believe that Google had updated their policy on sending to a group and so because the e-mail had a header that didn’t match the e-mail address it was sent from, then this was the cause of rejection.

By removing the header from the PHP mail send command, I can now send e-mails to the group. Whilst investigating I also performed the following

  • Added the full domain name to my DNS “MX” registration
  • Modified the file: “/etc/postfix/” so that the inet_protocols were set to ipv4 only.

Thanks to everyone who offered advice.

My answer:

Google is trying to send you a bounce message in response to the email that you delivered to them. But since your email doesn’t have a valid from address, it can’t be delivered to you.

Fix your application so that it sends email with a valid address.

View the full question and answer on Server Fault.

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