If you are having problems changing the Sender and Return-Path headers, make sure that you are editing the right configuration file. On my CentOS 5.6:
[root@server mail]# ll /usr/sbin/sendmail lrwxrwxrwx 1 root root 21 Oct 26 2009 /usr/sbin/sendmail -> /etc/alternatives/mta [root@server mail]# ll /etc/alternatives/mta lrwxrwxrwx 1 root root 23 Apr 9 07:48 /etc/alternatives/mta -> /usr/sbin/sendmail.exim [root@server mail]# ll /usr/sbin/sendmail.exim lrwxrwxrwx 1 root root 4 Apr 9 07:45 /usr/sbin/sendmail.exim -> exim
I spent some time trying to figure out why my changes to the sendmail.mc file were being ignored. Naturally, Exim configuration is different than Sendmail. You need to edit the /etc/exim/exim.conf file:
remote_smtp: driver = smtp return_path = firstname.lastname@example.org headers_rewrite = apache@* email@example.com s
Don't forget the "s" at the end. See this page for more information: http://www.exim.org/exim-html-2.00/doc/html/spec_32.html#SEC669
If you are OK with displaying the apache user name (ie "Sender: firstname.lastname@example.org") in the email header, then just update the qualify_domain configuration option in the same file.
qualify_domain = domain.com
This will fix the domain only (ie "Sender: email@example.com").
If you are indeed using Sendmail, then update your /etc/mail/sendmail.mc file.
LOCAL_DOMAIN(`domain.com')dnl MASQUERADE_AS(`domain.com')dnl FEATURE(`masquerade_envelope')dnl FEATURE(masquerade_entire_domain)dnl MASQUERADE_DOMAIN(`domain.com')dnl
If this configuration file does not exist, you need to install the sendmail-cf package first. Once you are done updating all the relevant configuration options, run the following command to generate your /etc/mail/sendmail.cf file.
make -C /etc/mail
Finally, restart sendmail:
service sendmail restart