• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
  • 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
  • Solutions
  • 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

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

Solutions: Send E-Mail from Linux Terminal

0
SHARES
4
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.

ADVERTISEMENT

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.

ADVERTISEMENT

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:

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

Next Post
Solutions: Configure SMB Share on Ubuntu 22.04

Solutions: Configure SMB Share on Ubuntu 22.04

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install SoftEther VPN Server on Ubuntu 24.04

Install SoftEther VPN Server on Ubuntu 24.04

Timeshift on Linux: How to Create and Restore System Snapshots

Timeshift on Linux: How to Create and Restore System Snapshots

Oracle VirtualBox: Port Forwarding in NAT Network Mode

Oracle VirtualBox: Port Forwarding in NAT Network Mode

Remote Desktop Access to Ubuntu 24.04 from Windows

Remote Desktop Access to Ubuntu 24.04 from Windows

Recent News

Install SoftEther VPN Server on Ubuntu 24.04

Install SoftEther VPN Server on Ubuntu 24.04

Timeshift on Linux: How to Create and Restore System Snapshots

Timeshift on Linux: How to Create and Restore System Snapshots

Oracle VirtualBox: Port Forwarding in NAT Network Mode

Oracle VirtualBox: Port Forwarding in NAT Network Mode

Remote Desktop Access to Ubuntu 24.04 from Windows

Remote Desktop Access to Ubuntu 24.04 from Windows

Fix "blk_update_request: critical target error" on Ubuntu Server (dev sdb, DISCARD Operation)

Fix “blk_update_request: critical target error” on Ubuntu Server with SSD (dev sdb, DISCARD Operation)

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

Browse by Category

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

Recent News

Install SoftEther VPN Server on Ubuntu 24.04

Install SoftEther VPN Server on Ubuntu 24.04

Timeshift on Linux: How to Create and Restore System Snapshots

Timeshift on Linux: How to Create and Restore System Snapshots

  • 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
  • Solutions
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.