How to send emails from command line

SendEmail is a lightweight command line SMTP agent. It was designed to be easily integrated in bash scripts, Perl programs etc. The program is in fact a Perl script, and it is distributed under GPL license. This is how you can send emails from command line using SendEmail and a regular gmail or yahoo account.

Installing SendEmail is easy:

$ sudo apt-get install  libio-socket-ssl-perl \
libnet-ssleay-perl sendemail

Sending an email using gmail.com is as follows:

$ sendemail -f username@gmail.com -t destination@domain.com \
-u "this is the subject of the message" \
-m "and this is the message" \
-s smtp.gmail.com -o tls=yes -xu username -xp password

username and password above are your gmail.com username and password. The message is encrypted using TLS. destination@domain.com is where you want the message to be sent.

Similarly for yahoo.com:

$ sendemail -f username@yahoo.com -t destination@domain.com \
-u "this is the subject of the message" \
-m "and this is the message" \
-s smtp.mail.yahoo.com -xu username -xp password

SendEmail comes with a regular man page and very extensive documentation accessible using –help option.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s