Tip Cache
Your source for tech tips
Tip: Manipulate the Return-Path of outgoing emails in Exim
Posted By: apeiro
Some MTAs require a valid email address in the Return-Path header. Here's how to set it explicitly.
In most setups, the receiving MTA attaches the Return-Path header based on the Envelope-From that's required in the SMTP conversation (MAIL FROM:). This field can't typically be controlled from a simple mail() call in PHP, but there's a way to do so if you're using Exim.
- Add the
apache(or whatever user your web server runs as) totrusted_usersinexim.conf:
trusted_users = mail : apache
- When calling the
mail()function in PHP, use the optional fifth parameter to pass in the-fswitch to set the Envelope-From:
mail('bob@example.com', 'Test', 'Testing!',
'From: bob@example.com', '-fbob@example.com');
Note: You can do a similar thing with Sendmail by adding the user to /etc/mail/trusted-users.
