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 Cloud VPS, Pure performance 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
/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:
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.