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.

Anyone knows how to configure sendmail mail server to do just
that ?

Vuong Ho.

add a comment

5 Answers

  • Votes
  • Oldest
  • Latest

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.

At any rate, you want the relay-domains file on the relay server. Enter the domains to route for, 1 per line. The location of this 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 scemes for sendmail and nobody there knows how to configure sendmail properly, you might want to do yourself a favor and get webmin ( http://www.webmin ) installed on the mail server. It's free.


add a comment

/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, usually enough, method is to define the DS (smart relay) macro in sendmail.cf. You should have a line with
change it in
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>
mail test from unix

mail server should answer something like mail sent. If this work you can try with a normal mail client like

mailx -s "subject" <email test>@<something out>
mail test from unix

To check if this has work look at /var/adm/syslog/mail.log
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

I have seen this used before for spam and virus scanning.
Were an outsourced company received outbound/inbound(mx) mail for the company. So every inbound mail is scanned for virus and spam.

I know in Exchange you would use a smarthost.

add a comment

vi /etc/mail/sendmail.cf

search for DS

"Smart" relay host (may be null)

DS<ip-address to relay>

restart sendmail.

add a comment

you can edit /etc/mail/sendmail.cf or /etc/sendmail.cf depend on your operating system.

and edit as

"Smart" relay host (may be null)




if you used dns name, or hostname ,pls make sure that your server can lookup ip from hostname.

referrence :

http://blogitknowledge.u-indy.com/syste ... l-quickly/

add a comment