My company has a need to relay all outgoing messages on our mail server (Sendmail) to a relay mail server for forwarding to the Internet. Does anyone know how to configure Sendmail Mail Server to do just that?
- 326.5k times
- Run the following from a command shell:
- Then search for DS and you will find something like:
# "Smart" relay host (may be null) DS<ip-address to relay>
<ip-address to relay>to be the IP address you want to relay.
- Restart Sendmail.
/etc/mail/relay-domains contains a list of hosts which are allowed to relay mail through your mail server. This list may consist of either specific hosts or whole domains.
/etc/mail/sendmail.cw (after Sendmail version 8.10, this file is local-host-names) contains a list of domains for which your mail server will accept mail. This list is usually the domains hosted by your machine.
NOTE: put a CR/LF at the end of the last domain. Otherwise, it won't work.
Of course, you have to set up your actual Sendmail server to use the mail relay.
If your Unix host has to use a mail relay to get out, the simplest method is to define the DS (smart relay) macro in
sendmail.cf. You should have a line with
DS. Change it in
mailrelay.domain is the FQDN of your mail relay as seen from your side. The stop/start Sendmail to let it reread the config file.
This mail relay must accept SMTP connection from your host and must accept relaying. To check if the mail relay is working try
telnet mailrelay.domain 25 .... answer from mail relay ..... helo <unix hostname> mail from: root@<unix hostname> rcpt to: <email test>@<something out> data mail test from UNIX .
The mail server should answer something like: mail sent. If this work you can try it with a normal mail client like
mailx -s "subject" <email test>@<something out> mail test from UNIX .
To check if this has worked look at
/var/adm/syslog/mail.log and you should see a couple of lines stating the mail has been accepted locally and sent to the relay and accepted.
You will want the relay-domains file on the relay server. Enter the domains to route for, 1 per line. The location of these files varies, but look in
/etc/sendmail/ or some such.
Also, if you're at the stage where you have to come up with complex routing schemes for Sendmail and nobody there knows how to configure Sendmail properly, you might want to do yourself a favor and get http://www.webmin installed on the mail server. It's free, and it will do much of the heavy lifting for you.
You can edit
/etc/sendmail.cf depend on your operating system. Edit as
# "Smart" relay host (may be null) DS<mailserver_hostname>
For example you might change it to:
# "Smart" relay host (may be null) DSmailserv.whathappen.com
If you used a DNS-based name or hostname, please make sure that your server can lookup the IP address for the hostname you specified.