Sending Emails From Terminal Using Gmail Account

By Vatsal Mevada on September 9, 2012 in For You & Me, How-Tos, Open Gurus, Sysadmins · 15 Comments

Linux terminal is one of the coolest tools I’ve ever come across. If you are also a fan of the terminal, and are a Gmail user, you should like this article.

Note: I’ve tested these steps on Ubuntu 12.04 and Fedora 16.

Security certificate

Before proceeding, we need Gmail’s security certificate on our system. Why? Gmail sends encrypted data over SSL (Secure Sockets Layer) for security; this certificate is necessary for encryption of data.

Ideally, you should have the file Equifax_Secure_CA.crt under /usr/share/ca-certificates/mozilla/. If you do, you’re ready to move on. If you don’t have it, steps 6 & 7 at http://www.chrisstreeter.com/archive/2009/04/305/gmail-imap-backup-with-mbsync-on-ubuntu may help you. Set the tls_trust_file parameter (in msmtp configuration, described below) to the path of the certificate file.

Installation

We need to install two packages–msmtp (a simple and easy-to-use SMTP client), and mailx (a utility program to send and receive emails). In a terminal, run the appropriate command for your distro; for systems supporting deb packages (e.g. Debian, Ubuntu, LinuxMint etc.), use sudo apt-get install msmtp heirloom-mailx; for systems supporting RPM packages (e.g. RedHat, Fedora etc.), use sudo yum install msmtp mailx.

Configuring msmtp

We need to create an msmtp configuration file

View the Original article

No comments:

Post a Comment

Thank You , For Immediate Assistance Plz Put Email Copy to Deviceporting@gmail.com