Set up SMTP relay with Sendmail

Estimated reading time: 1 min

Introduction

How to Set up SMTP relay with Sendmail? If you want or need to set up your mail server to send all outgoing mail to a specific server that will handle the delivery to the recipients you can use this article to set up your SMTP relay / Smarthost with Sendmail.

Prerequisites

  • A VPS or  Dedicated Server where sendmail is installed
  • You must be logged in via SSH as sudo or root user. This tutorial assumes that you are logged in as a sudo user.

Step 1: Log in using SSH

You must be logged in via SSH as sudo or root user. Please read this article for instructions if you don’t know how to connect.

Step 2: Configure the MTA

Edit /etc/mail/sendmail.mc  and find the following line

dnl define(`SMART_HOST', `smtp.your.provider')dnl

Replace it with the following line

define(`SMART_HOST', `smtprelay.snel.com')dnl
define(`RELAY_MAILER',`esmtp')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl

Step 3: Regenerate configuration file

Rebuild the configuration file with the following command:

/etc/mail/make

Step 4: Restart the mail server

Restart the mail server by issuing the following command:

service sendmail restart

Step 5: Send test email

echo "Test 1 from $(hostname -f)"|mail -s "Test 1 $(hostname -f)" [email protected]

Conclusion

Congratulations. You have installed SMTP relay / smarthost for your sendmail mail server.

Was this article helpful?
Dislike 38
Views: 101532

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *