Bennyland this server is running in my bedroom – benny’s learning how to run a linux server

18Jan/100

Forwarding all mail to your ISP’s smtp server with postfix and CentOS 5.4

I needed to forward all server mails to external email addresses and I had to use my ISP's smtp to do it. This is because everything is blocked by my ISP to combat spammers just making their own smtp server at home and then running it all hours of the day. To do this, you should have postfix installed and running already.

Setting up Postfix to use your ISP's smtp

Note: if your ISP requires authentication for smtp, you'll have to do some googleing.  If they don't (mine doesn't) then this will work fine for you.

vim /etc/postfix/main.cf

Next, you need to add the relayhost variable, you may have to enclose the domain in brackets, I didn't have to but I've read everywhere that you should:

relayhost = [your.isps.smtp.com]

Other items to potentially edit:

myhostname = your.host.name
mydomain = your.domain
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
relay_domains = $mydestination

Now, restart postfix

service postfix reload

Forwarding name@yourdomain.com to a real e-mail address

First things first, you need to edit main.cf

vim /etc/postfix/main.cf

Next, either add or edit the following lines. You can add as many domains as you want. If you followed the Perfect Server tutorial, you'll have all sorts of junk in these variables, just replace them.

virtual_alias_domains = yourdomain.com yourotherdomain.com.
virtual_alias_maps = hash:/etc/postfix/virtual

Now, edit the /etc/postfix/virtual file to add your forward rules:

vim /etc/postfix/virtual

forward all mail sent to *@yourdomain.com to your@email.com and name@yourotherdomain.com to your@email.com:

@yourdomain.com your@email.com
name@yourotherdomain.com your@email.com

Now, restart postfix

postmap /etc/postfix/virtual
service postfix reload
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.