Send Email (email)

There are many different ways to setup Email on a Linux system. Most packages are advanced mail servers for sending and receiving emails and they need quite some skills to setup. The following configuration is just for sending emails via curl, which most probably is already installed on your system.

Configuration file

To send an email this way you must use an SMTP mail server (MAILSERVER:MAILPORT) which sends your message to the mail server of the recipient. To avoid abuse you have to login on the mail server via MAILUSER and MAILPASSWORD. Finally you need to set the sender email address (MAILFROM).

Your indivual settings are stored in the configuration file /root/email.cfg


Email Script

The source code of the script can be found on Github

If you want to install it on your server and you don't know where to start, go to Some Simple Scripting.

Run this once just to make sure curl is installed:

apt install curl

If you already created the folder ~/scripts you can download email from Github and set execute rights to the script this way:

curl -s '' -o ~/scripts/email
chmod +x ~/scripts/email


Once you created the configuration file and downloaded the script you can start sending emails by using the following syntax:

email "Subject of the email" "Body text"

To send the content of a text file you can do so by

email "Subject of the email" /path/file.ext

Some Remarks

  • Currently you can only send to one recipient.
  • Only secure mail server communication is allowed (STARTTLS).
  • By default the script works only in combination with user root.

In case of an error check the exit code here: