How to Configure Sendmail for SMTP Relay with Port 587 ?
Introduction
[edit]Configuring Sendmail to act as an SMTP relay with port 587 allows you to relay outgoing emails through a specific server. This setup is commonly used for scenarios where you need to send emails from a server that may not have direct internet access. Below are step-by-step instructions on how to set up Sendmail for this purpose.
Prerequisites
[edit]1. Access to a Linux server.
2. Root or sudo privileges.
3. Basic knowledge of working with the command line.
Steps to Configure Sendmail for SMTP Relay with Port 587
[edit]Install Sendmail: Use the package manager to install Sendmail along with the necessary configuration files.
apt-get install sendmail sendmail-cf
Install SASL authentication service: If not already installed, install SASL (Simple Authentication and Security Layer) for authentication purposes.
apt-get install sasl2-bin
Configure SASL: Edit the SASL configuration file to enable the service.
vim /etc/default/saslauthd
Set START=yes.
Set Authorization Information: Define authentication credentials in the /etc/mail/authinfo file.
AuthInfo:abcd.com "U:abcd@gmail.com" "1234" "M:PLAIN"
Update Sendmail Configuration: Edit the Sendmail configuration file to include SMTP relay setup and authentication mechanisms.
vi /etc/mail/sendmail.mc
Add the following lines:
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl define(`SMART_HOST', `mail.irsis.ph')dnl define(`confAUTH_MECHANISMS', `EXTERNAL
GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash /etc/mail/authinfo')dnl
Update Configuration Files: Regenerate the Sendmail configuration file and update authentication database.
cd /etc/mail m4 sendmail.mc >sendmail.cf makemap hash authinfo < authinfo
Restart Sendmail Service: Restart the Sendmail service to apply the changes.
/etc/init.d/sendmail restart
Send Test Email: Verify the configuration by sending a test email.
echo "mail" | mail -s "Hello" abcd@gmail.com
Conclusion
[edit]By following these steps, you can successfully configure Sendmail to act as an SMTP relay with port 587, allowing your server to relay outgoing emails through a designated SMTP server. This setup ensures proper authentication and secure transmission of emails.
Remember to replace placeholders such as abcd.com, abcd@gmail.com, 1234, and mail.irsis.ph with your actual domain, email address, password, and SMTP server information respectively.