I'm using sendmail to send Mails from PHP and also forward some mails addressed to the server to a list of external mail-providers. The forwarding is done via an entry in /etc/mail/virtusertable:

test@domain.com testuser

In my /etc/aliases I include the mail list file:

testuser: ":include:/home/mail-list"

This setup works so far but I wanted to ask how it is possible to change the Reply-To Header of mails sent to the virtual user testuser via sendmail.mc? And if not is there another way to do this?

  • Have you considered using some filtering e.g. via procmail script? It will help to filter out spam based on "email list specific bayes". It will allow you to add/replace any headers you like.
    – AnFi
    May 26 '18 at 13:57

The proper way to set Reply-To is to do it in the MUA (PHP in your case), not in the MTA.


$to = 'bla@bla.com';
$subject = 'bla';
$message = 'bla';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n";

mail($to, $subject, $message, $headers);

More info: http://php.net/manual/en/function.mail.php

If you insist on rewriting addresses through sendmail, you shall use genericstable (see http://www.sendmail.com/sm/open_source/docs/m4/features.html#genericstable)

  • Add the following lines to sendmail.mc and recompile it:



  • create a map in /etc/genericstable to translate outgoing addresses. The file looks like this:

localuser newuser@newdomain

  • Convert the map to a hash db file by typing makemap hash /etc/genericstable.db < genericstable
  • I may not have been very clear about this in my original post: The mails I'm forwarding are not sent by php but instead com from an external mail provider to the sendmail MTA. May 26 '18 at 6:32
  • updated answer with alternative solutions based on genericstable May 26 '18 at 22:45

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.