Integrating Sendmail with Email Delivery
Use Sendmail to send emails through the Email Delivery service.
Configure Sendmail to Send Email Through Email Delivery
Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol used for email transport over the Internet. You can use Sendmail to send emails through Email Delivery. Before you use Sendmail you must configure Oracle Cloud Infrastructure Email Delivery in your Sendmail application.
These instructions contain sample code for your convenience and should be used as a reference. For client support, you must contact Sendmail customer support.
The steps below are for configuring Sendmail to send email through Oracle Cloud Infrastructure Email Delivery. These steps were tested on an Oracle Linux Server release 7.9 compute instance and Sendmail-8.14.7-6.el7.x86_64.
To enable Sendmail to integrate with Email Delivery:
-
Make sure Email Delivery is configured to send email. See Getting Started.
Note
SMTP credentials are required to configure Sendmail to use Email Delivery. Be sure to note the user name and password when you generate the SMTP credentials.
-
Run the following update and install commands:
sudo yum update sudo yum install sendmail sendmail-cf m4 cyrus-sasl-plain
-
Update
/etc/mail/authinfo
. Run the following command:sudo vi /etc/mail/authinfo
Note
If
/etc/mail/authinfo
doesn't exist, you can create it by running the commandsudo vi /etc/mail/authinfo
.Add the following line:
AuthInfo:<SMTP connection endpoint> "U:root" "I:<username from smtp credentials>" "P:<password from smtp credentials>" "M:PLAIN"
-
Generate the
/etc/mail/authinfo.db
file.Run the following command:
sudo sh -c 'makemap hash /etc/mail/authinfo.db < /etc/mail/authinfo'
-
Add support for relaying to the Oracle Cloud Infrastructure Email Delivery SMTP endpoint.
Run the following command:
sudo sh -c 'echo "Connect:<SMTP connection endpoint> RELAY" >> /etc/mail/access'
-
Regenerate
/etc/mail/access.db
.Run the following command:
sudo sh -c 'makemap hash /etc/mail/access.db < /etc/mail/access'
-
Create a backup of the
sendmail.cf
andsendmail.mc
files.Run the following command:
sudo sh -c 'cp /etc/mail/sendmail.cf /etc/mail/sendmail_cf.backup && cp /etc/mail/sendmail.mc /etc/mail/sendmail_mc.backup'
-
Update the
/etc/mail/sendmail.mc
file.Run the following command:
sudo vi /etc/mail/sendmail.mc
Find the
MAILER()
definitions.Type
/MAILER
and pressENTER
.In Insert mode, add the following settings before any
MAILER()
definitions:define(`SMART_HOST', `<SMTP connection endpoint>')dnl define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl FEATURE(`authinfo', `hash -o /etc/mail/authinfo.db')dnl MASQUERADE_AS(`<sending_domain>')dnl FEATURE(masquerade_envelope)dnl FEATURE(masquerade_entire_domain)dnl
Disable Insert mode.
-
Make Sendmail writeable.
Run the following command:
sudo chmod 666 /etc/mail/sendmail.cf
-
Regenerate
sendmail.cf
.Run the following command:
sudo sh -c 'm4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf'
Note
If you receive an error, such as "Command not found" or "No such file or directory," confirm that the m4 and sendmail packages are installed on your system.
-
Reset permissions for sendmail.cf to read only.
Run the following command:
sudo chmod 644 /etc/mail/sendmail.cf
-
Restart Sendmail.
Run the following command:
sudo /etc/init.d/service sendmail restart
-
Test the configuration by sending a test email.
Run the following command:
/usr/sbin/sendmail -vf <from_email_address> <recipient_email_address>
Enter the details of the email. After each line press
Enter
.For example:
From: <from_email_address> To: <recipient_email_address> Subject: OCI Email Delivery test email This is a test message sent from OCI Email Delivery using Sendmail.
Press
Ctrl + D
to send the email. -
Verify receipt of the test email.
Note
You can troubleshoot an issue by reviewing the Sendmail log on your mail server, located at
/var/log/mail.log
.
More Information
For more information, see the Sendmail Installation and Operation Guide.