Address rewriting allows changing outgoing email ID or domain name itself. This is good for hiding internal user names. For example:
SMTP user: tom-01
EMAIL ID: tom@domain.com
Server name: server01.hosting.com
However when tom-01 send an email from shell prompt or using php it looks like it was send from tom-01@server01.hosting.com
In some cases internal hosts have no valid Internet domain name, and instead use a name such as localdomain.local or something else. This can be a problem when you want to send mail over the Internet, because many mail servers reject mail addresses with invalid domain names to avoid spam.
Postfix MTA offers smtp_generic_maps parameter. You can specify lookup tables that replace local mail addresses by valid Internet addresses when mail leaves the machine via SMTP.
Open your main.cf file
# vi /etc/postfix/main.cf
Append following parameter
smtp_generic_maps = hash:/etc/postfix/generic
Save and close the file. Open /etc/postfix/generic file:
# vi /etc/postfix/generic
Make sure tom-01@server01.hosting.com change to tom@domain.com
tom-01@server01.hosting.com tom@domain.com
Save and close the file. Create or update generic postfix table:
# postmap /etc/postfix/generic
Restart postfix:
# /etc/init.d/postfix restart
When mail is sent to a remote host via SMTP this replaces tom-01@server01.hosting.com by tom@domain.com mail address. You can use this trick to replace address with your ISP address if you are connected via local SMTP.
- Email this to a friend
- Printable version
- Rss Feed
- Last Updated: Dec/28/2006
{ 7 comments… read them below or add one }
Hey, wasn’t sure where to contact you so I’ll leave it here.. I’m tagging you with the blog tag. Check out my post for more info :)
http://www.foogazi.com/2006/12/28/tag-im-it-5-things-you-did-not-know-about-me/
Thanks for tagging me. I have just posted my own list.
Appreciate your post.
Thanks this was helpful. I needed to be able to get my home server to forward mdadm alerts to my external email address through my isp’s smtp server (cox cable) and this was the missing piece.
I get this strange message from smtp.com in /var/spool/postfix/defer
I have found this message
for EVERY mail attempted sent via Postfix:
: host smtp.com.inbound10.mxlogic.net[208.65.144.3] said: 451
Could not load DRD for domain (1base.com) rcpt (eo@1base.com) (in reply to
RCPT TO command)
recipient=eo@1base.com
offset=133
status=4.0.0
action=delayed
reason=host smtp.com.inbound10.mxlogic.net[208.65.144.3] said: 451 Could not
load DRD for domain (1base.com) rcpt (eo@1base.com) (in reply to RCPT TO
command)
Thanks this was helpful. I needed to be able to get my home server to forward mdadm alerts to my external email address through my isp’s smtp server
Dear
Can you explain same for sendmail also.
Hey Vivek,
I would like something similar done, but only for one email address and not all the emails being sent out.
Any ideas?