I'm trying to get a python script to send mail (using smtplib.SMTP), but postfix is refusing to relay the message. I don't use the Ubuntu 10.10 Virtualmin server as a mail server (I happen to use google apps for that), but I want scripts to be able to send mail. Here is the log, with the addresses replsced with generic ones:

Apr 11 00:50:27 unimatrix-01 postfix/smtpd[25212]: connect from localhost[127.0.0.1]
Apr 11 00:50:27 unimatrix-01 postfix/smtpd[25212]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 554 5.7.1 <example@gmail.com>: Relay access denied; from=<noreply@example.info> to=<user@gmail.com> proto=ESMTP helo=<unimatrix-01.example.com>
Apr 11 00:50:27 unimatrix-01 postfix/smtpd[25212]: lost connection after RSET from localhost[127.0.0.1]
Apr 11 00:50:27 unimatrix-01 postfix/smtpd[25212]: disconnect from localhost[127.0.0.1]

I have already tried with no success, to fix this by running # dpkg-reconfigure postfix according to the Ubuntu Docs. How can I fix this?

Thanks in advance.

Update: Interestingly, apps using PHP can send mail just fine. So, I suspect it has something to do with postfix requireing authentication locally. This is not necessary as I am use sole user of this VP. I hope this helps with troubleshooting.

link|improve this question

feedback

2 Answers

up vote 1 down vote accepted

Check if you permit local networks to relay emails without authentication.

First of all, the following command, should include permit_mynetworks

sudo postconf smtpd_recipient_restrictions

Then check if 127.0.0.1 is in $mynetworks. Just do,

sudo postconf mynetworks

and check if 127.0.0.1 is there.

link|improve this answer
Success! Thanks! – Sean W. Apr 11 '11 at 13:18
feedback

I'm guessing you aren't setting mydomain anywhere, and thus are not telling postfix where it can deliver mail.

You essentially need to set mydomain = gmail.com and then add gmail.com or $mydomain to mydestination.

Make sure to reload/restart postfix

link|improve this answer
PHP apps can setil send mail via mail(). Would your guess affect that as well? – Sean W. Apr 11 '11 at 2:32
Honestly I'm not sure, I know I've seen this exact relay error before and this was the problem. Are you positive PHP is using postfix to send out? I would say try making the changes and see if this fixes it, but that my first recommendation. – rfelsburg Apr 11 '11 at 2:34
I tried as you suggested, and now postfix thinks that it's hosting the mailboxes for gmail.com Recipient address rejected: User unknown in local recipient table – Sean W. Apr 11 '11 at 2:38
Try setting mydomain to your domain but adding/keeping gmail.com in mydestination, also try adding to main.cf: debug_peer_list = 127.0.0.1 – rfelsburg Apr 11 '11 at 2:41
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.