• 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
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
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

Solutions: Send E-Mail from Linux Terminal

neo by neo
May 27, 2025
in Solutions
0
Solutions: Send E-Mail from Linux Terminal

Solutions: Send E-Mail from Linux Terminal

0
SHARES
9
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

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:

ADVERTISEMENT
ADVERTISEMENT
  • 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

defencedev.com

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

Solutions: Check Disk Usage on Ubuntu Terminal with ncdu Application

Next Post

Solutions: Configure SMB Share on Ubuntu 22.04

neo

neo

Related Posts

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)

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

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

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Next Post
Solutions: Configure SMB Share on Ubuntu 22.04

Solutions: Configure SMB Share on Ubuntu 22.04

Recommended

Fortinet FortiGate: Change Default Administration HTTPS and HTTP Port

Fortinet FortiGate: Port Forwarding for HTTPS NAT Configuration

How to Remove Application from an Ubuntu Server Manually

How to Remove Application from an Ubuntu Server Manually

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)

Home Lab with Fortinet FortiGate 60D Firewall

Home Lab with Fortinet FortiGate 60D Firewall

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

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

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)

Home Lab with Fortinet FortiGate 60D Firewall

Home Lab with Fortinet FortiGate 60D Firewall

  • 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

© 2025 defencedev.com - All rights reserved.