<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>klenwell press &#187; gmail</title>
	<atom:link href="http://klenwell.com/press/tag/gmail/feed/" rel="self" type="application/rss+xml" />
	<link>http://klenwell.com/press</link>
	<description>A Developer's Broadsheet</description>
	<lastBuildDate>Fri, 13 Jan 2012 14:51:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Command Line Email on Ubuntu (mailx version)</title>
		<link>http://klenwell.com/press/2009/03/ubuntu-email-with-mailx/</link>
		<comments>http://klenwell.com/press/2009/03/ubuntu-email-with-mailx/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 04:53:15 +0000</pubDate>
		<dc:creator>klenwell</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://klenwell.com/press/?p=114</guid>
		<description><![CDATA[For a simpler, updated version of this guide, see this page: http://klenwell.com/is/UbuntuCommandLineGmail This guide explains how to configure Ubuntu so that you can send email from the command line using mailx with your Gmail account for delivery. This updates a guide I originally posted on the ubuntu forums for mailx, which is part of the [...]]]></description>
			<content:encoded><![CDATA[<div class="redirect" style="font-weight:bold; padding:4px; border:1px solid blue; color:blue; border-width:1px 0;">For a simpler, updated version of this guide, see this page: <a href="http://klenwell.com/is/UbuntuCommandLineGmail">http://klenwell.com/is/UbuntuCommandLineGmail</a></div>
<p>This guide explains how to configure Ubuntu so that you can send email from the command line using mailx with your Gmail account for delivery.  This updates a guide I originally posted on the <a href="http://ubuntuforums.org/showthread.php?t=780509">ubuntu forums</a> for mailx, which is part of the current Ubuntu repositories (versions 7 and 8).  To use nail, for which this guide was originally drawn up, see <a href="http://www.klenwell.com/press/2009/03/ubuntu-email-with-nail/">this post</a>.</p>
<h4>In 5 Fairly Easy Steps</h4>
<p><strong>1. Install the needed programs</strong></p>
<div class="code">$ sudo apt-get install msmtp<br />
$ sudo apt-get install mailx</div>
<p><strong>2. Install Thawte certificates for Gmail</strong></p>
<p><strong>EDIT: verisign.com apparently no longer issues certs at the address below.  So the &#8216;wget&#8217; step will not work.</strong> adkein, in a comment below (<a href="#comment-146">click here</a>), links to another page when you can apparently get the needed cert.  I cannot vouch for this as my cert still works.  But you might try downloading that and putting it your ~/etc/.certs directory if you&#8217;re having issues finding the cert.</p>
<p>This is necessary for Gmail. (Thanks to <a href="http://laurentbois.com/2007/10/20/activemailer-using-msmtp-and-gmail/">laurentbois.com</a>.)</p>
<div class="code">$ mkdir -p ~/etc/.certs<br />
$ chmod 0700 ~/etc/.certs<br />
$ cd ~/etc/.certs<br />
$ wget https://www.verisign.com/support/thawte-roots.zip &#8211;no-check-certificate<br />
$ unzip thawte-roots.zip<br />
$ cp &#8216;Thawte Server Roots/ThawtePremiumServerCA_b64.txt&#8217; ThawtePremiumServerCA.crt</div>
<p><strong>3. Configure msmtp</strong><br />
This will open up a new msmtp configuration file</p>
<div class="code">$ gedit ~/.msmtprc</div>
<p>Copy the following lines. Replace UPPERCASE text with your personal settings:</p>
<pre class="brush: bash">
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
defaults
logfile /tmp/msmtp.log

# gmail account
#account gmail
auth on
host smtp.gmail.com
port 587
user YOURNAME@gmail.com
password YOURPASSWORD
from YOURNAME@gmail.com
tls on
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt

# set default account to use (not necessary with single account)
#account default : gmail
</pre>
<p>Change permission on this file or msmtp will complain:</p>
<div class="code">$ chmod 600 ~/.msmtprc</div>
<p><strong>4. Configure mailx</strong></p>
<div class="code">$ gedit ~/.mailrc</div>
<p>Copy the following lines and replace UPPERCASE text with your personal settings:</p>
<pre class="brush: bash">
# set smtp for nail
# ref: http://ubuntuforums.org/showpost.php?p=4531994&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;postcount=6

# gmail account (default)
# $ mailx -s &quot;subject line&quot; -a /path/file recipient@email.com &lt; /path/body.txt
set from=&quot;YOURNAME@gmail.com (YOURNAME)&quot;
set sendmail=&quot;/usr/bin/msmtp&quot;
set message-sendmail-extra-arguments=&quot;-a gmail&quot;
</pre>
<p><strong>5. Run a test</strong><br />
Send a test message to <a href="https://gmail.google.com/gmail">your gmail account</a>:</p>
<div class="code">$ echo -e &#8220;testing email from the command line&#8221; &gt; /tmp/test_email<br />
$ mailx -s &#8220;nail gmail test&#8221; YOURNAME@gmail.com &lt; /tmp/test_email</div>
<p>Check your gmail account and you should have a message from yourself.  You can also check your log:</p>
<div class="code">$ gedit /tmp/msmtp.log</div>
<p>I personally prefer <a href="http://www.klenwell.com/press/2009/03/ubuntu-email-with-nail/">nail</a> because it more easily accommodates multiple accounts.  But if you don&#8217;t have a deliberate need to use multiple accounts and are using a later version of Ubuntu, use this.</p>
]]></content:encoded>
			<wfw:commentRss>http://klenwell.com/press/2009/03/ubuntu-email-with-mailx/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Command Line Email on Ubuntu (nail version)</title>
		<link>http://klenwell.com/press/2009/03/ubuntu-email-with-nail/</link>
		<comments>http://klenwell.com/press/2009/03/ubuntu-email-with-nail/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 05:39:54 +0000</pubDate>
		<dc:creator>klenwell</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://klenwell.com/press/?p=110</guid>
		<description><![CDATA[For a simpler, updated version of this guide, see this page: http://klenwell.com/is/UbuntuCommandLineGmailNail This will be the first of two posts showing you how to configure the more recent versions of Ubuntu to send email from the command line as simply as humanly possible using your Gmail account for delivery. These instructions were originally posted on [...]]]></description>
			<content:encoded><![CDATA[<div class="redirect" style="font-weight:bold; padding:4px; border:1px solid blue; color:blue; border-width:1px 0;">For a simpler, updated version of this guide, see this page: <a href="http://klenwell.com/is/UbuntuCommandLineGmailNail">http://klenwell.com/is/UbuntuCommandLineGmailNail</a></div>
<p>This will be the first of two posts showing you how to configure the more recent versions of Ubuntu to send email from the command line as simply as humanly possible using your Gmail account for delivery.  These instructions were originally posted on <a href="http://phosphorusandlime.blogspot.com/2008/05/ubuntu-command-line-email.html">my old blog</a> and on the <a href="http://ubuntuforums.org/showthread.php?t=780509">Ubuntu forums site</a>.</p>
<p>This guide covers using the nail program, which is my client of choice but is no longer in the main repositories.  Find a guide for using mailx, which is part of the current Ubuntu repositories, <a href="http://www.klenwell.com/press/2009/03/ubuntu-email-with-mailx/">here</a>.</p>
<h4>In 6 Fairly Easy Steps</h4>
<p><strong>1. Add the breezy repositories containing nail to your source file</strong><br />
Edit your sources list</p>
<div class="code">$ sudo gedit /etc/apt/sources.list</div>
<p>Add the following lines at bottom.  These will enable you to apt-get nail</p>
<pre class="brush: bash"># breezy repositories (added to install nail)
# see http://old-releases.ubuntu.com/releases/ for more info
deb http://old-releases.ubuntu.com/ubuntu/ breezy universe</pre>
<p>Don&#8217;t forget to update</p>
<div class="code">$ sudo apt-get update</div>
<p><strong>2. Install the needed programs</strong></p>
<div class="code">$ sudo apt-get install msmtp<br />
$ sudo apt-get install nail</div>
<p><strong>3. Install Thawte certificates for Gmail</strong></p>
<p><strong>EDIT: verisign.com apparently no longer issues certs at the address below.  So the &#8216;wget&#8217; step will not work.</strong> According to <a href="http://www.klenwell.com/press/2009/03/ubuntu-email-with-mailx/#comment-146">this comment</a>, you can downloaded the needed cert from <a href="http://www.cs.utexas.edu/~suriya/UT-wireless/ThawtePremiumServerCA_b64.txt">http://www.cs.utexas.edu/~suriya/UT-wireless/ThawtePremiumServerCA_b64.txt</a>.  I cannot vouch for this as my cert still works.  But you might try downloading that and putting it your ~/etc/.certs directory if you&#8217;re having issues finding the cert.</p>
<p>This is necessary for Gmail. (Thanks to <a href="http://laurentbois.com/2007/10/20/activemailer-using-msmtp-and-gmail/">laurentbois.com</a>.)</p>
<div class="code">$ mkdir -p ~/etc/.certs<br />
$ chmod 0700 ~/etc/.certs<br />
$ cd ~/etc/.certs<br />
$ wget https://www.verisign.com/support/thawte-roots.zip &#8211;no-check-certificate<br />
$ unzip thawte-roots.zip<br />
$ cp Thawte Server Roots/ThawtePremiumServerCA_b64.txt ThawtePremiumServerCA.crt</div>
<p><strong>4. Configure msmtp</strong><br />
This will open up a new msmtp configuration file</p>
<div class="code">$ gedit ~/.msmtprc</div>
<p>Copy the following lines. Replace UPPERCASE text with your personal settings:</p>
<pre class="brush: bash">
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
defaults
logfile /tmp/msmtp.log

# isp account
account isp
auth login
host SMTP.YOURISP.COM
port 25
user YOURNAME@ISP.COM
from YOURNAME@ISP.COM
password YOURPASSWORD

# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user YOURNAME@gmail.com
password YOURPASSWORD
from YOURNAME@gmail.com
tls on
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt

# set default account to use (from above)
account default : gmail
</pre>
<p>Change permission on this file or msmtp will complain:</p>
<div class="code">$ chmod 600 ~/.msmtprc</div>
<p><strong>5. Configure nail</strong></p>
<div class="code">$ gedit ~/.mailrc</div>
<p>Copy the following lines and replace UPPERCASE text with your personal settings:</p>
<pre class="brush: bash">
# set smtp for nail
# ref: http://ubuntuforums.org/showpost.php?p=4531994&amp;amp;amp;amp;amp;amp;amp;postcount=6

# gmail account (default)
# $ nail -s &quot;subject line&quot; -a /path/file recipient@email.com &lt; /path/body.txt
set from=&quot;YOURNAME@gmail.com (YOURNAME)&quot;
set sendmail=&quot;/usr/bin/msmtp&quot;
set message-sendmail-extra-arguments=&quot;-a gmail&quot;

# isp account (add -A option to command line)
# $ nail -A isp -s &quot;subject line&quot; -a /path/file recipient@email.com &lt; /path/body.txt
account isp {
set from=&quot;YOURNAME@ISP.COM&quot;
set sendmail=&quot;/usr/bin/msmtp&quot;
set message-sendmail-extra-arguments=&quot;-a isp&quot;
}
</pre>
<p><strong>6. Run a test</strong><br />
Send a test message to <a href="https://gmail.google.com/gmail">your gmail account</a>:</p>
<div class="code">$ echo -e &#8220;testing email from the command line&#8221; &gt; /tmp/test_email<br />
$ nail -s &#8220;nail gmail test&#8221; YOURNAME@gmail.com &lt; /tmp/test_email</div>
<p>Check your gmail account and you should have a message from yourself.  You can also check your log:</p>
<div class="code">$ gedit /tmp/msmtp.log</div>
<p>That&#8217;s it.  You should now be ready to incorporate email into your bash scripts, which is great for making backups.  I did successfully test this on an old laptop had installed Ubuntu 8.04 this weekend.</p>
<p>If you have any problems or questions, I&#8217;d recommend posting to the <a href="http://ubuntuforums.org/showthread.php?t=780509">ubuntu forums thread</a> as you&#8217;ll probably get a quicker response there.</p>
]]></content:encoded>
			<wfw:commentRss>http://klenwell.com/press/2009/03/ubuntu-email-with-nail/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

