Setting up Gmail to work from Command line on Ubuntu
After some looking around, particularly this post on Ubuntu email with Mailx (which is incomplete, if you follow all the instructions, you will realise that the certificate he is talking about does not exist in the tgz that you download) and a few others, I got my mailx to work with my gmail account.
I guess you can try setting up an MTA such as exim and use sendmail or even mail, but that seemed quite complicated and I wanted to send out a mail from my shell script as quickly as possible.
Here are the steps involved which I wrote up as a little shell script:
#! /bin/sh sudo apt-get install ca-certificatessudo update-ca-certificatessudo apt-get install msmtp mailxecho "# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-filedefaultslogfile /tmp/msmtp.log # gmail accountaccount gmailauth onhost smtp.gmail.comport 587user EMAILpassword PASSWORDfrom EMAILtls ontls_trust_file /etc/ssl/certs/ca-certificates.crt# set default account to use (not necessary with single account)account default : gmail" > ~/.msmtprcchmod 600 ~/.msmtprc echo "# set smtp for nailset from=\"EMAIL (YOUR NAME)\"set sendmail=\"/usr/bin/msmtp\"set message-sendmail-extra-arguments=\"-a gmail\"" > ~/.mailrc echo "Edit CAPTIALS in .msmtprc and .mailrc and run a test message like this:"echo "echo Message | mailx -s \"this is subject\" user@email.com\n"
Enjoy!
Related posts:












Interesting! But you can already configure Gmail so many email clients on Ubuntu, why use command line (academic interest?)?
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
good....................................................................................................