Asked
Updated
Viewed
327.8k times

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?

  • 0
    You just need to set up relaying on the relay server and make your local server use that as a gateway. My question is - why bother? It seems like an unnecessary hop. If it's because you're behind a firewall, you're going to tie up that firewall just as much having it flat out send as you will having it forward to another server to send for you. — this213
add a comment
0

4 Answers

  • Votes
  • Oldest
  • Latest
Answered
Updated
  1. Run the following from a command shell: vi /etc/mail/sendmail.cf
  2. Then search for DS and you will find something like:
    # "Smart" relay host (may be null)
    DS<ip-address to relay>
    
  3. Change <ip-address to relay> to be the IP address you want to relay.
  4. Restart Sendmail.
add a comment
1
Answered
Updated

/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 DSmailrelay.domain where 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.

Good luck.

add a comment
1
Answered
Updated

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/mail/ or /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.

add a comment
0
Answered
Updated

You can edit /etc/mail/sendmail.cf or /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.

add a comment
0