send email via CLI (Command Line Interface)

how to send email using terminal – CLI mode.

You need to have root access for this ;

# mail -s “test email” isp@google.com -c owner@google.com -b staff@google.com

This would send a blank email with “test email” as its subject. The email would be send to isp@google.com with CC to owner@google.com and blind CC to staff@google.com

# echo “How are you” | mail -s “test email” isp@google.com -c owner@google.com -b staff@google.com

would include “How are you” line as the body message of the email. This could be useful and incorporated from your shell scripts that does a particular function and informs you by email of its function result.

Another way is to

# mutt -s “test email” -a /root/pic.jpg isp@google.com -c owner@google.com -b staff@google.com

would send email with “test emai” as subject name. Email is addressed to isp@google.com, with CC to owner@google.com and BCC to staff@google.com. You will noticed the new parameter. This email would attached /root/pic.jpg picture to this email.

Now, piping it like so

# echo “How are you” | mutt -s “test email” -a /root/pic.jpg isp@google.com -c owner@google.com -b staff@google.com

would include “How are you” as body of the email.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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