In our earlier tutorial we had discussed about
SSMTP for sending email through SMTP server via command line. This tutorial make this process much easier using sendemail command line utility. SendEmail is an Lightweight command line SMTP email client for sending emails through SMTP server. In this article we have described to how to install sendemail package and few example commands for sending email through remote smtp server like Gmail.
Install SendEmail
SendEmail SMTP client is available under default Ubuntu repositories, Use following commands to install it.
$ sudo apt-get update $ sudo apt-get install sendemail
Send Email through SMTP
Example 1:-
In this example email body text is passed as argument (-o message-file=/tmp/mailbody.txt) in command.
$ sendemail -l email.log -f "sender@domain.com" -u "Email Subject 1" -t "receiver@domain.com" -s "smtp.gmail.com:587" -o tls=yes -xu "youremail@gmail.com" -xp "Email Password" -o message-file="/tmp/mailbody.txt"
Example 2:-
In this example email body text is passed as piped input from other command output. You can also include cc and bcc email address as well.
$ cat mailbody.txt | sendemail -l email.log -f "sender@domain.com" -u "Email Subject 2" -t "receiver@domain.com" -cc "receiver2@domain.com" -bcc "receiver3@domain.com" -s "smtp.gmail.com:587" -o tls=yes -xu "youremail@gmail.com" -xp "Email Password"
Thanks for Visit Here
Comments
Post a Comment