Command line email


Here’s a recipe for setting up ssmtp which will allow you to send email from the command line like a Ninja.
Ninja code begins here:

ssmtp -au me@gmail.com -ap mypassword -v recipient@ninja.victim.com < ~/shuriken.txt

How do you get to this stage? Here’s an /etc/ssmtp/ssmtp.conf file that sends to the gmail ssmtp.

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# See the ssmtp.conf(5) man page for a more verbose explanation of the
# available options.
#

# The person who gets all mail for userids < 500
# Make this empty to disable rewriting.
root=me@gmail.com

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=smtp.gmail.com:465

# Use SSL/TLS to send secure messages to server.
UseTLS=YES

And the corresponding /etc/ssmtp/revaliases file. This maps your user login name to an email address to place in the from header of the email.

# sSMTP aliases
#
# Format:	local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
your_login_name:myemail@ninja.com:smtp.gmail.com:465


About this entry