• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Bash Scripting

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

by neo
September 3, 2026
in Bash Scripting
0
Solutions: Send E-Mail from Linux Terminal

Solutions: Send E-Mail from Linux Terminal

0
SHARES
32
VIEWS
Share on FacebookShare on LinkedIn
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.

#
# 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:

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!

Tags: automationlinux
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

Related Posts

Terminal Colors in Bash: How and When to Use Them
Bash Scripting

Terminal Colors in Bash: How and When to Use Them

Automating Linux Server Health Checks with a Bash Script
Bash Scripting

Automating Linux Server Health Checks with a Bash Script

Solution: Monitoring Disk Usage with Email Alert Using a Bash Script and Crontab on Linux
Bash Scripting

Disk Usage Monitoring with Bash and Cron

Lesson 11: Practical Linux Bash Examples and Projects
Bash Scripting

Lesson 11: Practical Linux Bash Examples and Projects

Lesson 10: Bash File Operation (Read, Write, Copy)
Bash Scripting

Lesson 10: Bash File Operation (Read, Write, Copy)

Lesson 9: Bash Maths Operations (Bash Arithmetic) Examples
Bash Scripting

Lesson 9: Bash Maths Operations (Bash Arithmetic) Examples

Next Post
Solutions: Configure SMB Share on Ubuntu 22.04

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

Recommended

Proxmox Freezes Due to e1000e NETDEV WATCHDOG Error – Fix

Proxmox Freezes Due to e1000e NETDEV WATCHDOG Error

Image Optimizer – Convert and Resize Photos in Browser (No Upload Required)

Image Optimizer – Convert and Resize Photos in Browser (No Upload Required)

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

Fix Proxmox VM Snapshot “Out of Space” Errors

Fix Proxmox VM Snapshot “Out of Space” Errors

Categories

  • Linux
    • Bash Scripting
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Web Tools

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

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

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

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools

© 2025 defencedev.com - All rights reserved.