I needed to configure a sendmail server that had a dynamic IP address to route email out through an SMTP server belonging to an ISP, since otherwise some email servers might reject email from that sendmail server. Some email servers will compare a sending email server's IP address to lists of addresses known to be assigned by ISP's as dynamic IP addresses. By doing so, ISP's hope to block spam from home user's PCs that have been compromised and put to use as zombie systems by spammers.
The steps below can be taken on a Linux system running sendmail to have it send email via a "smart host" server. In essence, instead of the sendmail server sending email directly to other email servers, it transmits all email to another server, the "smart host", which handles the task of transmitting the received email to the recipients' servers.
/etc/mail/sendmail.mc, look for the following section:
dnl # Uncomment and edit the following line if your outgoing mail needs to dnl # be sent out through an external mail server: dnl # dnl define(`SMART_HOST', `smtp.your.provider')dnl dnl #
dnl from the beginning of the
dnl define(`SMART_HOST', `smtp.your.provider')dnl line and
smtp.your.provider with the smart host you will be
/etc/mail/access add the following line, substituting
the actual SMTP server you will need to use for
and your actual username and password on the smart host server for
Authinfo:mail.example.com "U:myloginname" "P:mypasswd" "M:Plain"
Then regenerate the
/etc/mail/access.db file with
makemap hash /etc/mail/access </etc/mail/access.
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf.
Then restart sendmail with
service sendmail restart or
Once you have taken the above steps, you can send a test message from the system. Sending one to a test email address on another system that will allow you to view the message headers is ideal. At the destination, look at the message headers for the email you sent. You should see it passing through the smart host.
When I sent out a test message after making the changes above, the message
didn't reach the destination. I checked the mail queue with
and saw the message had not gone out because of an "AUTH failure".
# mailq /var/spool/mqueue (1 request) -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- m43M1HT8032701 31 Sat May 3 18:01 <email@example.com> (Deferred: Temporary AUTH failure) <firstname.lastname@example.org>
I had sendmail attempt to send the queued message immediately and display
information on its progress with
sendmail -q 0 -v (the
-v provides "verbose" information).
# sendmail -q 0 -v Running /var/spool/mqueue/m43M1HT8032701 (sequence 1 of 1) <email@example.com>... Connecting to smtp.atlanticbb.net. via relay... 220 ECHO Labs SMTP Service - MX01 >>> EHLO myserver.com 250-BL-106 says EHLO to 22.214.171.124:1097 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-AUTH=LOGIN 250 AUTH LOGIN >>> QUIT 221 BL-106 closing connection <firstname.lastname@example.org>... Deferred: Temporary AUTH failure Closing connection to smtp.atlanticbb.net.
In this case I was using smtp.atlanticbb.net as the smart host. I could
see it supports an AUTH type of "LOGIN", but I didn't see "PLAIN" listed.
Authinfo:smtp.atlanticbb.net "U:myloginname" "P:mypasswd" "M:Login"
I then ran
makemap hash /etc/mail/access < /etc/mail/access
again. Then when I had sendmail process the mail queue immediately again,
the message was successfully transmitted.
# sendmail -q 0 -v Running /var/spool/mqueue/m43M1HT8032701 (sequence 1 of 1) <email@example.com>... Connecting to smtp.atlanticbb.net. via relay... 220 ECHO Labs SMTP Service - MX02 >>> EHLO myserver.com 250-BL-206 says EHLO to 126.96.36.199:2430 250-8BITMIME 250-PIPELINING 250-AUTH=LOGIN 250-AUTH LOGIN 250 ENHANCEDSTATUSCODES >>> AUTH LOGIN 334 VXNlcm4hcWU6 >>> bW9vbnBvbW40 334 UGFzc2dvdmQ6 >>> MVN0b2A1Njd= 235 Authed. Go on. >>> MAIL From:<firstname.lastname@example.org> 250 MAIL FROM accepted >>> RCPT To:<email@example.com> >>> DATA 250 Recipient Accepted - Will relay per rbIP 354 continue. finished with "\r\n.\r\n" >>> . 250 OK D4/2C-23466-1B9EC184 <firstname.lastname@example.org>... Sent (OK D4/2C-23466-1B9EC184) Closing connection to smtp.atlanticbb.net. >>> QUIT 221 BL-206 closing connection