Cookie Consent by Free Privacy Policy Generator 📌 SMTP & mailutils: How to send your mails via the Linux terminal.

✅ SMTP & mailutils: How to send your mails via the Linux terminal.

💡 Newskategorie: Programmierung
🔗 Quelle:

Table of Contents

  1. Introduction
  2. Prerequisite
  3. Generate Google App password
  4. Launch your EC2 Instance
  5. Configuration of SSMTP
  6. Write and send your mail
  7. Conclusion

1. Introduction

Imagine being able to compose, attach files and send emails directly from your CLI using a few concise Linux commands. Well, the Linux terminal offers a streamlined and efficient alternative for sending emails using mailutils and the Simple Mail Transfer Protocol (SMTP).

What is SMTP?
SMTP stands for Simple Mail Transfer Protocol. It is a protocol used by email servers to send and receive email messages over the Internet. For instance, the email you send is transferred over the internet from one server to the other using SMTP.

What is mailutils?
The mailutils is a set of versatile utilities that manages emails directly from the CLI or Linux terminal using SMTP and other protocols. Some of the utilities include:
mail: This utility allows you to read and send emails interactively from the command line.
movemail: A utility that moves mail from one location to another.
frm: A utility to list the subject lines of email in a mailbox.
readmsg: A utility to read and print messages.

This article will provide a guide on how to send mail seamlessly via the Linux terminal using SMTP and mailutils.

Now, let's get started.

2. Prerequisite

For this article, you will need:
i. A Google account for your app password generation
ii. A Linux terminal. I used the AWS console. You can sign up for a free 1yr tier account here

3. Generate Google App Password

On your Google account, locate the settings icon and click on manage your Google account. Take a look at the image attached below:

Google Account

Next, go to the security settings and turn on your 2-step verification.
Two-step verification

Scroll down the 2-step verification page and click on the App passwords. Type a name for your app and a password will be generated automatically. Make sure to copy and save this password as we will need it later.
See the images attached below:

App Password

Generated App Password

4. Launch EC2 Instance

Once you log in on your AWS console, in the search bar, type EC2 and click on EC2. Click on instance and choose a name for your instance. See image below

EC2 Instance

Select your AMI. For this article, we will use the Ubuntu AMI. So, go ahead and select your Ubuntu AMI.

Click on Launch instance.

Next, click on instance ID. See the image below

instance id
Then connect to the terminal

Connect to your terminal

5. Configuration of SMTP

i. On your terminal, run sudo apt update

Sudo apt update
This command is run before installing new software with apt install to ensure you get the latest versions of packages and all their dependencies.

ii. Install mailutils
sudo apt update mailutils

Please know that while the installation is running, a postfix configuration will pop up, select the internet site option using your arrow keys and then click ok to finish up with the installation.

iii. Install SSMTP

Why install SSMTP?

SSMTP is a simple mail transfer agent (MTA) used to send emails from a Linux system. In other words, it forwards emails to another SMTP server for delivery.

To install SSMTP
sudo apt install ssmtp


iv. Configuration of SSMTP file
To configure the ssmtp file, sudo nano /etc/ssmtp/

Conf file command

With the arrow keys, edit your ssmtp configuration file to look exactly like the images attached below

SSMTP Conf File

SSMTP Conf File
In this configuration file,
Your root should be your email address.
Your AuthUser should be your email address.
Your AuthPass should be the 16-character string generated from the app password in your Google account. When typing it in, remember not to include the spaces.
The rewriteDomain should be, but if you are not using Gmail's SMTP server to send your email, replace with your domain.
Lastly, uncomment the FromLineOverride as shown in the image above.
Save your file.

6. Write and send your mail

To send your mail, run the command below
echo "I'm a Cloud Engineer" | mail -s "Hello there!" your email address
Send email
Once this is done, check your Gmail to see the mail.

Gmail inbox

This is how to use SMTP and mailutils to send emails from the Ubuntu terminal.

6. Conclusion

Congratulations on successfully setting up your Linux terminal to send emails using SMTP and mailutils! You've learned how to configure your environment step by step, from generating a Google App password to launching an EC2 instance and configuring SSMTP.

Sending emails from the command line can be a powerful and efficient way to handle communications, especially in automated scripts or remote environments. By following this guide, you've gained valuable insights into how SMTP works and how to leverage it within your Linux terminal.

Your feedback is important to me! If you encounter any issues or have suggestions for improvement, please don't hesitate to share your thoughts. Your insights can help refine this guide and make it even more helpful for others.


✅ SMTP & mailutils: How to send your mails via the Linux terminal.

📈 82.23 Punkte

✅ Configure Postfix to Send Email with Gmail's SMTP From the Terminal

📈 33.51 Punkte

✅ Ruby bis 2.3.x SMTP Net::SMTP erweiterte Rechte

📈 28.49 Punkte

✅ cURL bis 7.60 SMTP lib/smtp.c Curl_smtp_escape_eob --limit-rate Pufferüberlauf

📈 28.49 Punkte

✅ MAILsweeper for SMTP SMTP/Exchange denial of service

📈 28.49 Punkte

✅ University of Cambridge Exim 3.22 Batched SMTP Mode SMTP Header Format String

📈 28.49 Punkte

✅ University of Cambridge Exim 3.22 Batched SMTP Mode SMTP Header Format String

📈 28.49 Punkte

✅ Goodtech Systems GoodTech SMTP server 5.16 SMTP Server Stack-based memory corruption

📈 28.49 Punkte

✅ Ruby up to 2.3.x SMTP Net::SMTP command injection

📈 28.49 Punkte

✅ cURL up to 7.60 SMTP lib/smtp.c Curl_smtp_escape_eob --limit-rate memory corruption

📈 28.49 Punkte

✅ CVE-2024-6694 | WP Mail SMTP Plugin up to 4.0.1 on WordPress SMTP Password information disclosure

📈 28.49 Punkte

✅ Mutt – A Command Line Email Client to Send Mails from Terminal

📈 28.15 Punkte

✅ Send Emails in your React JS App with SMTP Express

📈 27.98 Punkte

✅ Send to Kindle - Send your personal documents to your Kindle.

📈 27.47 Punkte

✅ GNU Mailutils 0.5/0.6 memory corruption [CVE-2005-1523]

📈 25.76 Punkte

✅ GNU Mailutils 0.5/0.6 denial of service [CVE-2005-1522]

📈 25.76 Punkte

✅ GNU Mailutils 0.5/0.6 fetch_io END memory corruption

📈 25.76 Punkte

✅ GNU Mailutils 0.5/0.6 header.c header_get_field_name memory corruption

📈 25.76 Punkte

✅ GNU mailutils auth/sql.c sql_escape_string sql injection

📈 25.76 Punkte

✅ GNU Mailutils 0.6 search.c memory corruption

📈 25.76 Punkte

✅ [local] GNU Mailutils 3.7 - Privilege Escalation

📈 25.76 Punkte

✅ GNU Mailutils 3.7 Privilege Escalation

📈 25.76 Punkte

✅ Ausführen von Code mit höheren Privilegien in GNU Mailutils (Gentoo)

📈 25.76 Punkte

✅ CVE-2019-18862 | GNU Mailutils up to 3.7 maidag privileges management (ID 155425)

📈 25.76 Punkte

✅ SMTP.js – Send Email without a Server from the Browser

📈 24.87 Punkte

✅ New SMTP Smuggling Attack Lets Hackers Send Spoofed Emails

📈 24.87 Punkte

✅ How to send emails using Python and SMTP server

📈 24.87 Punkte

✅ How to Send Bulk Emails For Free using SMTP (Beginner's Guide)

📈 24.87 Punkte

✅ No terminal? No problem. Terminal-based Tetris clone netris now playable via web browser

📈 23.87 Punkte


Datei nicht gefunden!