This is how I set up an SMTP relay server for outbound e-mail. I use this type of configuration so that I can have my servers send out messages without having to configure them to authenticate with my internet providers SMTP server. I’ll write scripts that use mailx to send mail to my phone, or configure the ILOM’s of my servers to send out mail based on certain events. (Try calling Verizon or Comcast support and tell them you’re having a problem getting mailx to send e-mail through their SMTP servers and see how far you get.)
As long as you’re internet gateway has a static IP and a registered domain name most mail routers will accept outbound e-mail sent with this configuration.
In the following sample environment there are a set of Solaris servers that exist in a local DNS domain that is different than my public DNS domain. We’ll say the public domain name is mycompany.com and the Solaris systems will be on an internally managed domain called solservers.mycompany.com. The masquerade_envelope feature allows me to configure the domain portion of the e-mail address so that it shows my public DNS name instead of the internal.
Here is a sample configuration of a Solaris 10 SMTP server.
# cd /etc/mail/cf/cf
# cp main.mc new.mc
# vi new.mc
divert(0)dnl
VERSIONID(`@(#)sendmail.mc 1.11 (Sun) 06/21/04′)
OSTYPE(`solaris8′)dnl
DOMAIN(`solaris-generic’)dnl
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)
DAEMON_OPTIONS(`Port=smtp,Addr=192.168.1.25, Name=MTA’)
MASQUERADE_AS(`mycompany.com’)
FEATURE(masquerade_envelope)
MAILER(`local’)dnl
MAILER(`smtp’)dnl
# /usr/ccs/bin/make new.cf
# cp new.cf /etc/mail/sendmail.cf
# svcadm restart sendmail
The DAEMON_OPTIONS lines will configure your SMTP server to forward mail that is sent to either of those IP addresses. The assumption here is that this server has an IP address of 192.168.1.25 and other mail clients will be sending mail to this system for forwarding. If you only want this system to forward it’s own mail, and reject other client mail forward requests, then get rid of the second line.
…And here is a sample sendmail client configuration that will forward it’s mail through this sever.
# cd /etc/mail/cf/cf
# cp main.cf new.cf
# vi new.mc
divert(0)dnl
VERSIONID(`@(#)sendmail.mc 1.11 (Sun) 06/21/04′)
OSTYPE(`solaris8′)dnl
DOMAIN(`solaris-generic’)dnl
define(`SMART_HOST’, `smtp.solservers.mycompany.com’)dnl
MASQUERADE_AS(`mycompany.com’)
FEATURE(`masquerade_envelope’)
MAILER(`local’)dnl
MAILER(`smtp’)dnl
# /usr/ccs/bin/make new.cf
# cp new.cf /etc/mail/sendmail.cf
# svcadm restart sendmail
The assumption here is that there is an entry on the internal DNS server that points smtp.solservers.mycompany.com to the IP address 192.168.1.25.