Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to prevent my php scripts from sending mails through the MTA in localhost 25, without authentication.

I have been told that the server, by default, trusts itself, and that's why I need no auth in this case. So I have to disable the 'unauthenticated local relay'. How can I achieve that in postfix?

share|improve this question
    
I liked @Cedric answer it made sense, but I tried to apply this on my local postfix machine and tried phpmailer it still send the email as well. I had removed permit_mynetworks but phpmailer script is still sending. reference to this got me here after I disabled auth in the script link here postfix was rebooted etc... this puzzles me as well... – gstlouis 12 hours ago

Within your Postfix configuration, you can use the setting smtpd_recipient_restrictions in order to decide who should be able do use your server as a relay.

For example, in my config it looks like this:

smtpd_recipient_restrictions = 
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unauth_destination

That means that every one from my network (see also the mynetworks setting) and everyone who is authenticated can send email. Simply remove permit_mynetworks, and nobody will be able to send email without authentication anymore. Just be aware that this might break other programs that currently rely on being able to send you email without authentication, and not just your PHP application.

share|improve this answer

Are you sure your scripts send email over TCP connection to localhost? This is quite uncommon, local emails are usually injected into postfix maildrop queue directly.

share|improve this answer
    
No I'm not sure =p. I'm using a php library that receives as arguments 'localhost' and 25. I don't know what it does with them, but it can send mails even when I don't use the next method 'authenticate', which receives as arguments a login and a password. – HappyDeveloper Feb 10 '11 at 21:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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