Skip to content

Instantly share code, notes, and snippets.

@William-Lake
Last active February 27, 2018 13:57
Show Gist options
  • Save William-Lake/6eb8d8f5b08e0251b5df3589ead788a4 to your computer and use it in GitHub Desktop.
Save William-Lake/6eb8d8f5b08e0251b5df3589ead788a4 to your computer and use it in GitHub Desktop.
How to send email from terminal.

How to send email from Terminal

Instructions 3, 5 from here

Instruction 6 from here

  1. Install mutt
sudo apt-get install mutt
  1. Create email account (mail.com is the setup used here)

  2. Create folder

sudo touch /var/mail/<username>
sudo chmod 660 /var/mail/<username>
sudo chown `whoami`:mail /var/mail/<username>
  1. Create mutt configuration file
sudo vi ~/.muttrc
  1. Fill mutt config file with correct info

Note: See additional .muttrc file.

  1. Send email

    • Compose message in a .txt file and save:
    sudo vi email.txt
    • Send with just message
    echo "" | mutt -s "<Subject Line>" -i email.txt [email protected]

    Thanks to: https://www.thegeekdiary.com/linux-unix-send-mail-with-attachment-using-mutt/

    • Send with attachment
    echo "" | mutt -s "<Subject Line>" -i email.txt -a Attachment.txt [email protected]
set realname = "<yourname>"
set from = "<mail.com email address>"
set use_from = yes
set envelope_from = yes
set smtp_url = "smtp://<mail.com email address>@smtp.mail.com:587/"
set smtp_pass = "<mail.com email address password>"
set spoolfile = "+INBOX"
set ssl_force_tls = yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment