How to install and configure ssmtp on a Linux server

Last updated December 6th, 2023 00:11

In Linux, the program ssmtp (Simple SMTP) is used for sending emails using the Simple Mail Transfer Protocol (SMTP). Ssmtp is a simple SMTP client that allows sending emails from the command line or other applications on Linux. Ssmtp works by receiving an email message from input (either directly from the command line or from another program) and sending it to the target SMTP server. This server then receives the email and delivers it to the specified email address. In this article, we will show you how to install and configure ssmtp on a Linux server in a few simple steps.

How to install and configure ssmtp on a Linux server

Ssmtp is easily configurable and requires minimal settings. It usually requires configuring the /etc/ssmtp/ssmtp.conf file, where information about the SMTP server is entered, such as the server address, port, username, and password for authentication. Additional options can also be set, such as the sender’s address. To begin, install ssmtp using the following command:

				
					sudo apt-get install ssmtp
				
			

After the installation is complete, open the ssmtp.conf configuration file using the command:

				
					sudo nano /etc/ssmtp/ssmtp.conf
				
			

In the configuration file, modify these lines:

				
					root=your_email@domain.tld
mailhub=smtp.server.tld:587
hostname=your_server_hostname
UseSTARTTLS=YES
AuthUser=your_email@domain.tld
AuthPass=your_email_password
FromLineOverride=YES
Charset=utf-8
				
			
How to install and configure ssmtp on a Linux server

Test the ssmtp configuration

Once you have modified the configuration file, save the changes using the CTRL+X keyboard shortcut, and confirm the change by pressing the Y key. You can then perform a configuration test. Create a file named test_email.txt and open it for editing:

				
					nano test_email.txt
				
			

Insert the following content into the test_email.txt file:

				
					To: recipient_email@example.com
From: your_email@yourdomain.tld
Subject: Test message
Content-Type: text/plain

This is a test message from SSMTP.
				
			

Replace recipient_email@example.com with the actual recipient’s email address and your_email@yourdomain.tld with the actual sender’s email address. Save and close the test_email.txt file. Send the test email using the following command:

				
					ssmtp recipient_email@example.com < test_email.txt
				
			

Replace recipient_email@example.com with the actual recipient’s email address. If you have correctly modified the configuration file, ssmtp should send the email. You can further use ssmtp in various simple bash scripts, such as sending warning notifications when the disk is full (a script via CRON checks the disk usage, and if it exceeds a certain threshold, ssmtp is used to send an email with a warning to free up disk space).

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Nejstarší
Nejnovější Nejvíce hlasováno
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje