• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

How to Send E-Mail from Linux Terminal – Quick & Easy Guide

neo by neo
September 11, 2025
in Solutions
0
Solutions: Send E-Mail from Linux Terminal

Solutions: Send E-Mail from Linux Terminal

0
SHARES
14
VIEWS
Share on FacebookShare on Twitter
Table of Contents
  • Send E-Mail from Terminal
    • Introduction
    • Install SSMTP Application on Linux
    • Send Test E-Mail from Terminal
  • Check out More Similar Guides

Send E-Mail from Terminal

Sending emails directly from the Linux terminal can be a powerful and efficient way to manage communication, automate tasks, and monitor system activities. The ability to send an email from the command line removes the need for a full-fledged email client and allows for streamlined processes in automated scripts or systems administration.

There are many scenarios where terminal-based email functionality becomes crucial:

  • Automating Notifications: Send alerts when a scheduled task finishes, when a threshold is reached (e.g., disk space usage, CPU usage, number of sessions ), or if a system failure occurs.
  • Script Integration: Automate reporting processes, like sending log files, system status reports, or backups via email without manual intervention.
  • Remote Administration: For remote Linux servers, sending email directly from the terminal allows you to quickly communicate with administrators or users from within scripts or cron jobs.
  • Efficiency: The command line provides a fast and resource-efficient way to send email without needing a graphical interface or third-party applications.

Introduction

Send e-mail from the Linux terminal can be a powerful tool for automating system alerts and sending quick notifications. I use this approach for various checks and reports that are generated on my Linux machines. I put the email sending scripts in a crontab and in this way automate sending reports and notifications that I have previously prepared.

In this guide, we’ll walk you through the steps to configure and send emails from the terminal using various utilities like mailutils and ssmtp.

By the end, you’ll be able to integrate email functionality into your scripts.

Install SSMTP Application on Linux

Step 1: Install ssmtp and mailtuils to send E-Mail

Before sending emails from the command line, install the required packages: ssmtp and mailutils. These tools provide a straightforward way to set up and manage email delivery on your Linux system.

To install the packages, run the following commands:

sudo apt install ssmtp
sudo apt install mailutils

ssmtp handles the email sending via an SMTP server, while mailutils provides additional tools for mail operations.

Step 2: Put your Parameters in ssmtp Configuration

To configure ssmtp open the configuration file in a text editor:

sudo nano /etc/ssmtp/ssmtp.conf

You need to edit /etc/ssmtp/ssmtp.conf the file and put your e-mail address, mail server configuration and other parameters.

ADVERTISEMENT
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
Root=user@mail.com
#FromLineOverride=YES

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mail.server.com:port

# Use TLS encryption
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=mail.com

# The full hostname
hostname=HOSTNAME
AuthUser=user@mail.com
AuthPass=password

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES

In this example:

  • mailhub: The address of the SMTP server.
  • AuthUser: Your email address.
  • AuthPass: Your email password (or App password if 2FA is enabled).
  • UseTLS and UseSTARTTLS: Ensures secure encrypted communication with the SMTP server

Send Test E-Mail from Terminal

To send an e-mail from terminal, you can use this command:

ADVERTISEMENT
echo "Body of your email" | mail -s "Test E-Mail Subject" user@mail.com

Check out More Similar Guides

If you found this guide on sending emails from the Linux terminal helpful, you might also like these related tutorials on Linux system optimization and automation:

  • How to Monitor Disk Usage on Linux with Email Alerts Using a Bash Script and Cron
    Learn how to set up email alerts for disk usage on your Linux server using Bash scripts and Cron jobs.
  • How to Monitor Disk Usage on Linux and Automatically Receive Email Alerts
    This guide will show you how to automatically monitor disk usage and get email notifications when your disk space exceeds a certain threshold.

Explore these and other useful tutorials on DefenceDev for more tips and tricks on managing your Linux system!

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

Check Disk Usage on Ubuntu Terminal Using ncdu – Easy & Fast Guide

Next Post

How to Configure SMB Share on Ubuntu 22.04 – Step-by-Step Guide

neo

neo

Related Posts

Automatic Windows Service Monitoring and Restart Script
Solutions

Automatic Windows Service Monitoring and Restart Script

Host a Website on Raspberry Pi – Real Benchmark Tests
Solutions

Host a Website on Raspberry Pi – Real Benchmark Tests

My Ultimate Docker Command Cheat Sheet (2025 Edition)
Docker

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script
Docker

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script

Raspberry Pi Monitoring with Monit: Docker, Temperature, Network & More
Solutions

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Next Post
Solutions: Configure SMB Share on Ubuntu 22.04

How to Configure SMB Share on Ubuntu 22.04 – Step-by-Step Guide

Recommended

MikroTik: How to Create a Backup of Mikrotik Configuration

MikroTik: How to Create a Backup of Mikrotik Configuration

Nextcloud: My Experience Collected in 2 Years of Use

Nextcloud: A Two-Year User Experience Review

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Online WebP to JPG Converter

Online WebP to JPG Converter

Image Metadata Remover – Clean EXIF and GPS Info Securely

Image Metadata Remover – Clean EXIF and GPS Info Online

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • Web Tools
ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Online WebP to JPG Converter

Online WebP to JPG Converter

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.