Mail Relay/Transport Setup

By admin

I had to set up a relay with sendmail, because i'll never remember, here's what I did:

Synopsis: Server1 is running postfix. It needs to send all it's mail out through Server2 which is running sendmail is and the main mail server for the domain (eg mydomain.com)

HOWTO:
1) Set up sendmail on Server2 to relay for server1:
a) vi /etc/mail/relay-domains
b) add (where 10.0.6.5 is the ip of Server1):

10.0.6.5 RELAY

c) do these 2 commands to make it stick:

sudo makemap hash /etc/mail/access.db < /etc/mail/access
sudo /etc/init.d/sendmail restart

2) Set up postfix on server1 to use a transport. This means it sends it's mail out through server2.
a) add this line to /etc/postfix/main.cnf

transport_maps = hash:/etc/postfix/transport

b) create /etc/postfix/transport and this line to it (where 10.0.6.101 is the ip of the relay server, server1):

* smtp:10.0.6.101

c) execute these command for it to take effect:

sudo postmap /etc/postfix/transport”
sudo /etc/init.d/postfix restart

d) One last thing to do, since Server2 is sendint e-mail from mydomain.com, gotta make server 1 do that too (otherwise it may send from myhost.mydomain.com), edit /etc/mailname and change the value to mydomain.com. This one took a while for me to find!

3) Test it out. I created a stupid php script to test if from the command line, to save me typing in the future here it is:

$ cat t.php

$to = 'kevin@kenglish77.com';
$subject = 'Test e-mail ' . date('c');
$body = 'HI FORM PHP ' . date('c');
mail( $to, $subject, $body );

?>



categoriaLinux commentoNo Comments dataAugust 15th, 2007

About... admin

This author published 340 posts in this site.

Share

FacebookTwitterEmailWindows LiveTechnoratiDeliciousDiggStumbleponMyspaceLikedin

Leave a comment