Set up SMTP relay with Sendmail

Estimated reading time: 1 min


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.


  • 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/  and find the following line

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

Replace it with the following line

define(`SMART_HOST', `')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl

Step 3: Regenerate configuration file

Rebuild the configuration file with the following command:


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]


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

Was this article helpful?
Dislike 36
Views: 97470

Reader Interactions

Leave a Reply

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