You are not logged in.
Login or Register

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) to trusted_users in exim.conf:
trusted_users = mail : apache
  • When calling the mail() function in PHP, use the optional fifth parameter to pass in the -f switch 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.