Friday, October 2, 2009

Episode 3: Using Sendmail to Change the Sender's Email Address

1) Add these statements to your /etc/mail/sendmail.mc file to activate the feature:

FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl

2) Create a /etc/mail/generics-domains file that is just a list of all the domains that should be inspected. Make sure the file includes your server's canonical domain name, which you can obtain using the command:



[root@Innova ~]# sendmail -bt -d0.1
> You have new mail in /var/spool/mail/root
[root@Innova ~]#

Here is a sample /etc/mail/generics-domains file:
[root@Innova ~]# cat /etc/mail/generics-domains

intinfra.com
Innova.intinfra.com



3) Create your /etc/mail/genericstable file. First sendmail searches the /etc/mail/generics-domains file for a list of domains to reverse map. It then looks at the /etc/mail/genericstable file for an individual email address from a matching domain. The format of the file is

mailadmin mailadmin@intinfra.com
ajeet ajeet@intinfra.com


Run m4 command followed by service restart for the sendmail to work.
This time if you send mail as:

[mailadmin ~]$ echo "hello" | mail -v -s "hello" ajeetraina@gmail.com

The Mail will arrive as:

mailman@intinfra.com and not root@host.domain.com

No comments:

Post a Comment