Difference between revisions of "Configure Sendmail Relays - CentOS 7"

From Michael's Information Zone
Jump to navigation Jump to search
(Created page with "<ref>http://serverfault.com/questions/215388/how-to-configure-sendmail-to-relay-through-a-specific-server</ref> Looking in the /etc/mail/sendmail.mc file add a smarthost entry...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
==Purpose==
 +
To configure sendmail to send email.
 +
==Basic Relay Config==
 +
This will change the server you send emails through, instead of looking up MX records and sending directly to the recipient. Such as Amazon SES<br>
 
<ref>http://serverfault.com/questions/215388/how-to-configure-sendmail-to-relay-through-a-specific-server</ref> Looking in the /etc/mail/sendmail.mc file add a smarthost entry that looks like the following
 
<ref>http://serverfault.com/questions/215388/how-to-configure-sendmail-to-relay-through-a-specific-server</ref> Looking in the /etc/mail/sendmail.mc file add a smarthost entry that looks like the following
 
<br>
 
<br>
 
  define(`SMART_HOST', `insidemail.tld')dnl
 
  define(`SMART_HOST', `insidemail.tld')dnl
 
I had to use a fqdn and a host entry to resolve it with. There is a way to use an IP but I have not spent enough time working on this. Just needed it to send mail internally for now.
 
I had to use a fqdn and a host entry to resolve it with. There is a way to use an IP but I have not spent enough time working on this. Just needed it to send mail internally for now.
 +
==SMTP Authentication==
 +
For when you want to send emails using an external SMTP server that requires authentication.<ref>https://unix.stackexchange.com/questions/204299/centos-sendmail-smtp-smarthost-with-authentication</ref><ref>https://access.redhat.com/solutions/60803</ref>
 +
===Amazon SES===
 +
<ref>https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-sendmail.html</ref><ref>https://www.drupal.org/forum/support/installing-drupal/2003-02-10/mail-being-rejected-data-format-error</ref>
 +
<pre>
 +
yum install sendmail sendmail-cf
 +
sed -i 's/smtp\.your\.provider/email-smtp\.us-east-1\.amazonaws\.com/; s/^dnl\ define(`SMART/define(`SMART/' /etc/mail/sendmail.mc
 +
sed -i 's/dnl\ define(`confAUTH_MECHANISMS/define(`confAUTH_MECHANISMS/' /etc/mail/sendmail.mc
 +
echo "FEATURE(\`authinfo',\`hash /etc/mail/authinfo.db')dnl" >> /etc/mail/sendmail.mc
 +
echo "AuthInfo:email-smtp.us-east-1.amazonaws.com    \"U:username\" \"P:password\" \"M:PLAIN\"" >> /etc/mail/authinfo
 +
makemap hash /etc/mail/authinfo < /etc/mail/authinfo
 +
echo "Connect:email-smtp.us-east-1.amazonaws.com RELAY" >> /etc/mail/access
 +
makemap hash /etc/mail/access.db < /etc/mail/access
 +
 +
systemctl restart sendmail
 +
 +
</pre>

Latest revision as of 12:55, 4 May 2018

Purpose

To configure sendmail to send email.

Basic Relay Config

This will change the server you send emails through, instead of looking up MX records and sending directly to the recipient. Such as Amazon SES
[1] Looking in the /etc/mail/sendmail.mc file add a smarthost entry that looks like the following

define(`SMART_HOST', `insidemail.tld')dnl

I had to use a fqdn and a host entry to resolve it with. There is a way to use an IP but I have not spent enough time working on this. Just needed it to send mail internally for now.

SMTP Authentication

For when you want to send emails using an external SMTP server that requires authentication.[2][3]

Amazon SES

[4][5]

yum install sendmail sendmail-cf
sed -i 's/smtp\.your\.provider/email-smtp\.us-east-1\.amazonaws\.com/; s/^dnl\ define(`SMART/define(`SMART/' /etc/mail/sendmail.mc
sed -i 's/dnl\ define(`confAUTH_MECHANISMS/define(`confAUTH_MECHANISMS/' /etc/mail/sendmail.mc
echo "FEATURE(\`authinfo',\`hash /etc/mail/authinfo.db')dnl" >> /etc/mail/sendmail.mc
echo "AuthInfo:email-smtp.us-east-1.amazonaws.com    \"U:username\" \"P:password\" \"M:PLAIN\"" >> /etc/mail/authinfo
makemap hash /etc/mail/authinfo < /etc/mail/authinfo
echo "Connect:email-smtp.us-east-1.amazonaws.com RELAY" >> /etc/mail/access
makemap hash /etc/mail/access.db < /etc/mail/access

systemctl restart sendmail