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

From Michael's Information Zone
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 9: Line 9:
 
==SMTP Authentication==
 
==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>
 
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>
 
<pre>
 
yum install sendmail sendmail-cf
 
yum install sendmail sendmail-cf
Line 16: Line 18:
 
echo "AuthInfo:email-smtp.us-east-1.amazonaws.com    \"U:username\" \"P:password\" \"M:PLAIN\"" >> /etc/mail/authinfo
 
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
 
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
 
systemctl restart sendmail
  
 
</pre>
 
</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