Introduction
Sendmail SMTP Relay Configuration allows a server to send outgoing emails through an external SMTP relay using port 587. Sendmail uses SMTP authentication to connect to the relay server and send emails.
In this guide, we will explain how to install Sendmail, configure SASL authentication, update the Sendmail configuration files, and test email delivery using SMTP relay with port 587.
Steps to Configure Sendmail SMTP Relay with Port 587
Step 1: Install Sendmail
First, install Sendmail and the Sendmail configuration package using the following command:
apt-get install sendmail sendmail-cf
Step 2: Check and Install SASL Authentication
Check whether the saslauthd service is available on the server.
If it is not installed, install it using the following command:
apt-get install sasl2-bin
Step 3: Enable the SASL Authentication Service
Open the SASL authentication configuration file:
vim /etc/default/saslauthd
Find the start parameter and change its value to:
start=yes
By default, the value will be set to no.
Step 4: Configure SMTP Authentication Information
Open the authentication information file:
vim /etc/mail/authinfo
Add the following line, replacing the sample values with your SMTP relay provider’s details:
AuthInfo:your-relay-domain.com "U:your-username" "P:your-password" "M:PLAIN"
Step 5: Configure the Sendmail SMTP Relay
Open the Sendmail configuration file:
vi /etc/mail/sendmail.mc
Scroll down to the end of the file and add the following SMTP relay configuration lines:
dnl # SMTP Relay setup define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl define(`SMART_HOST', `your-smtp-relay-host')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash /etc/mail/authinfo')dnl
Replace the SMTP relay hostname with your actual SMTP provider’s hostname.
Step 6: Update Sendmail Configuration and Authentication Database
Navigate to the Sendmail configuration directory:
cd /etc/mail
Update the sendmail.cf and authinfo.db files using the following commands:
Generate the Sendmail configuration file:
m4 sendmail.mc > sendmail.cf
Generate the authentication database:
makemap hash authinfo < authinfo
Step 7: Restart the Sendmail Service
Restart the Sendmail service to apply the configuration changes:
/etc/init.d/sendmail restart
Step 8: Send a Test Email
Use the following command to send a test email:
echo "mail" | mail -s "Hello" recipient@example.com
Replace recipient@example.com with the email address where you want to receive the test message.
Step 9: Check Email Delivery
Wait for some time and check the recipient’s inbox to verify whether the test email has been delivered successfully.
Conclusion
Configuring Sendmail with an SMTP relay on port 587 allows servers to send outbound emails through an external mail server. By installing Sendmail, configuring SASL authentication, updating the relay settings, and sending a test email, you can complete the SMTP relay configuration.
Official Documentation
- Sendmail – SMTP AUTH Configuration
- Oracle Linux – Configuring a Sendmail Client
- Oracle Linux – Sendmail Configuration Files
How Pheonix Solutions Can Help
Looking for reliable email server configuration and DevOps solutions?
Pheonix Solutions provides DevOps, cloud infrastructure, server administration, and email configuration services to help businesses maintain reliable IT environments.
Our experts can help you configure SMTP relays, manage Sendmail services, troubleshoot email delivery issues, and maintain server infrastructure.
Contact our experts to discuss your requirements.
