Postfix is setup for

relayhost = spamfilter.example.com:25

I have a few php scripts running on the same server as postfix that send emails via the mail command (sendmail) to various email addresses (example@gmail.com). Is it possible to ignore the relayhost for mail originating from I'd like the server to attempt delivery directly instead of relaying to our spam filter (spamfilter.example.com)


It's possible to change the transport (sender_dependent_default_transport_maps) or relayhost (sender_dependent_relayhost_maps) used depending on sender envelope address. If the PHP scripts are run as different users than mail users, this is a very suitable solution.

In your PHP script you can even set envelope sender and From: address separate using 5th optional parameter to give envelope sender directly to Sendmail:

mail($to, $subject, $message, $headers,'-f envelope@example.com');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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