View Categories

How to setup SMTP in Raspberry PI

2 min read

 

MigoSMTP

MigoSMTP

How to Set Up SMTP in Raspberry Pi #

In this tutorial, we will learn how to configure SMTP (Simple Mail Transfer Protocol) on a Raspberry Pi. SMTP allows you to send email notifications or alerts from your Raspberry Pi projects or applications. By following these steps, you’ll be able to set up SMTP quickly and easily.

Requirements:

  • Raspberry Pi
  • Internet connection

Step 1: Update your Raspberry Pi Open a terminal and run the following commands

Step 2: Install the necessary packages In the terminal, enter:

sudo apt update 
sudo apt upgrade
sudo apt install ssmtp mailutils

 

Step 3: Configure SSMTP Enter the following command to open the configuration file:

sudo nano /etc/ssmtp/ssmtp.conf

Replace the file’s contents with the following:

root=your-email@example.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
hostname=your-hostname
UseTLS=YES
UseSTARTTLS=YES
AuthUser=your-email@example.com
AuthPass=your-email-password
FromLineOverride=YES

Replace your-email@example.com with your email address, your-email-password with your email password, and your-hostname with a desired name to identify your Raspberry Pi.

Step 4: Save the changes and exit the editor.

Step 5: Configure the mail name Open the revaliases file by entering:

sudo nano /etc/ssmtp/revaliases

Replace the existing contents with:

pi:your-email@example.com:smtp.gmail.com:587

Replace your-email@example.com with your email address.

Step 6: Update the Raspberry Pi’s hostname Enter the following command to open the hostname file:

sudo nano /etc/hostname

Replace the existing hostname with the name you specified in the ssmtp.conf file.

Step 7: Update the hosts file Open the hosts file by entering:

bash
sudo nano /etc/hosts

Replace the existing hostname with the name you specified in the ssmtp.conf file.

Step 8: Restart the Raspberry Pi To apply the changes, reboot your Raspberry Pi:

sudo reboot

Conclusion: Congratulations! You have successfully set up SMTP on your Raspberry Pi. You can now send email notifications or alerts from your projects or applications. Remember to keep your email configuration secure and follow best practices to protect your Raspberry Pi.

Feel free to customize the settings as per your requirements. If you have any further questions, leave a comment below.

Enjoy using SMTP on your Raspberry Pi!


MigoSMTP

MigoSMTP

Powered by BetterDocs

Leave a Reply

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

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from Youtube
Vimeo
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Spotify
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound