in Uncategorized

Send Email Attachment from Ubuntu Command Line

The ability to send e-mail alerts is essential for the day to day management of any VPS.

Install mailutils

# For ubuntu/debian based distro 
$ sudo apt-get install mailutils

Now its time to send an email attachment using mail command a shown.

$ echo "Put Message Body Here" | mail -s "Put Subject Here" [email protected] -A

In the above command:

  • -s – specifies the message subject.
  • -A – helps to attach a file.

Note: You would need postfix or ssmtp to be already installed to deliever mail to outside world.