<?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>Marcus Nyberg &#187; ssmtp</title>
	<atom:link href="http://www.marcusnyberg.com/category/ssmtp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcusnyberg.com</link>
	<description>Digital and dangerous</description>
	<lastBuildDate>Fri, 03 Feb 2012 08:41:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sending email in FreeBSD with Gmail</title>
		<link>http://www.marcusnyberg.com/2010/03/09/sending-email-in-freebsd-with-gmail/</link>
		<comments>http://www.marcusnyberg.com/2010/03/09/sending-email-in-freebsd-with-gmail/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 12:19:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[ssmtp]]></category>

		<guid isPermaLink="false">http://www.marcusnyberg.com/?p=452</guid>
		<description><![CDATA[When I moved my mail functionality (gmail) from my FreeBSD-server to Google Apps I was left with no way to send email from my server (sendmail disabled and gmail removed) from shell. I have no longer the need to recieve email from my server, thanks to Google! However, I needed to send emails from my [...]]]></description>
			<content:encoded><![CDATA[<p>When I <a href="http://www.marcusnyberg.com/2008/12/30/flytt-av-mailhanteringen-till-google-apps/">moved my mail functionality</a> (gmail) from my FreeBSD-server to Google Apps I was left with no way to send email from my server (sendmail disabled and gmail removed) from shell. I have no longer the need  to recieve email from my server, thanks to Google! However, I needed to send emails from my server to report server status and report software/hardware errors. </p>
<p>This is how I solved the problem on my FreeBSD 7.0 server.</p>
<p>1. Freebsd has a guide for <a href="http://www.freebsd.org/doc/handbook/outgoing-only.html">setting up send only with ssmtp</a>. First you should install ssmtp.</p>
<p><code>cd /usr/ports/mail/ssmtp/ &#038;&#038; make install clean</code></p>
<p>2. Then you need to configure ssmtp for Gmail. Create this file in /usr/local/etc/ssmtp/ssmtp.conf. Replace email and password with your Gmail-account settings.</p>
<p><code>root=youremail@gmail.com<br />
mailhub=smtp.gmail.com:587<br />
AuthUser=youremail@gmail.com<br />
AuthPass=yourpassword<br />
UseSTARTTLS=YES</code></p>
<p>3. Test ssmtp. First you have to create a textfile with the message that you are going to send. Copy the text between the lines below.</p>
<p>Save the text to &#8221;testmessage.txt&#8221;.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
To: youremail@gmail.com<br />
From: youremail@gmail.com<br />
Subject: Testmessage</p>
<p>This is a test</code><br />
--------------------------</p>
<p>Then run this command to send the testmessage.</p>
<p><code>ssmtp -v youremail@gmail.com < testmessage.txt</code></p>
<p>You should see the following output:</p>
<p>[<-] 220 mx.google.com ESMTP 14sm2982172ewy.10<br />
[->] EHLO mysql<br />
[<-] 250 PIPELINING<br />
[->] STARTTLS<br />
[<-] 220 2.0.0 Ready to start TLS<br />
[->] EHLO servername<br />
[<-] 250 PIPELINING<br />
[->] AUTH LOGIN<br />
[<-] 334 VXNlcm5hbWU6<br />
[->] bWFyY3VzLm55YkBnbWFpbC5jb20=<br />
[<-] 334 UGFzc3dvcmQ6<br />
[<-] 235 2.7.0 Accepted<br />
[->] MAIL FROM:<root@mysql><br />
[<-] 250 2.1.0 OK 14sm2982172ewy.10<br />
[->] RCPT TO:<youremail@gmail.com><br />
[<-] 250 2.1.5 OK 14sm2982172ewy.10<br />
[->] DATA<br />
[<-] 354  Go ahead 14sm2982172ewy.10<br />
[->] Received: by Servername (sSMTP sendmail emulation); Tue, 09 Mar 2010 12:53:14 +0100<br />
[->] From: "Username" <username@servername><br />
[->] Date: Tue, 09 Mar 2010 12:53:14 +0100<br />
[->] To: youremail@gmail.com<br />
[->] Subject: Testmessage<br />
[->]<br />
[->] This is a test<br />
[->] .<br />
[<-] 250 2.0.0 OK 1268135596 14sm2982172ewy.10<br />
[->] QUIT<br />
[<-] 221 2.0.0 closing connection 14sm2982172ewy.10</p>
<p>If everything seems ok you should now have a fresh email in your Gmail account. Check it out! If not, then you should probably check your ssmtp.conf file and verify that you can connect to smtp.google.com</p>
<p>4. Last, replace sendmail with ssmtp. This makes ssmtp the default mailer for your system.</p>
<p><code>mv  /usr/sbin/sendmail  /usr/sbin/sendmail.org<br />
ln -s /usr/local/sbin/ssmtp /usr/sbin/sendmail</code></p>
<p>5. Check that mail is working.</p>
<p><code>mail -v -s "TestSubject" youremail@gmail.com<br />
Testing and<br />
.</code></p>
<p>Output:<br />
[<-] 220 mx.google.com ESMTP 16sm3004137ewy.7<br />
[->] EHLO mysql<br />
[<-] 250 PIPELINING<br />
[->] STARTTLS<br />
[<-] 220 2.0.0 Ready to start TLS<br />
[->] EHLO servername<br />
[<-] 250 PIPELINING<br />
[->] AUTH LOGIN<br />
[<-] 334 VXNlcm5hbWU6<br />
[->] bWFyY3VzLm55YkBnbWFpbC5jb20=<br />
[<-] 334 UGFzc3dvcmQ6<br />
[<-] 235 2.7.0 Accepted<br />
[->] MAIL FROM:<username@servername><br />
[<-] 250 2.1.0 OK 16sm3004137ewy.7<br />
[->] RCPT TO:<youremail@gmail.com><br />
[<-] 250 2.1.5 OK 16sm3004137ewy.7<br />
[->] DATA<br />
[<-] 354  Go ahead 16sm3004137ewy.7<br />
[->] Received: by mysql (sSMTP sendmail emulation); Tue, 09 Mar 2010 13:11:41 +0100<br />
[->] From: "Username" <username@servername><br />
[->] Date: Tue, 09 Mar 2010 13:11:41 +0100<br />
[->] To: youremail@gmail.com<br />
[->] Subject: TestSubject<br />
[->]<br />
[->] testing<br />
[->] .<br />
[<-] 250 2.0.0 OK 1268136703 16sm3004137ewy.7<br />
[->] QUIT<br />
[<-] 221 2.0.0 closing connection 16sm3004137ewy.7</p>
<p>6. Check the log file.</p>
<p><code>cat /var/log/maillog</code></p>
<p>Output:<br />
SMTP[755]: Creating SSL connection to host<br />
sSMTP[755]: SSL connection using RC4-MD5<br />
sSMTP[755]: Sent mail for username@servername(221 2.0.0 closing connection 14sm3068161ewy.2) uid=0 username=username outbytes=696<br />
sSMTP[1234]: Creating SSL connection to host<br />
sSMTP[1234]: SSL connection using RC4-MD5<br />
sSMTP[1234]: Sent mail for username@servername (221 2.0.0 closing connection 16sm3004137ewy.7) uid=0 username=username outbytes=349</p>
<p><strong>Summary</strong><br />
This worked for me straight out of the box. I didn't need to make any changes to make it work. I hope it works for you as well!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcusnyberg.com/2010/03/09/sending-email-in-freebsd-with-gmail/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

