<?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>CertPal &#187; mail</title>
	<atom:link href="http://www.certpal.com/blogs/tag/mail/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.certpal.com/blogs</link>
	<description>Technology and certifications</description>
	<lastBuildDate>Mon, 18 Jul 2011 06:48:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Commons email</title>
		<link>http://www.certpal.com/blogs/2009/11/commons-email/</link>
		<comments>http://www.certpal.com/blogs/2009/11/commons-email/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 15:49:01 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[commons]]></category>
		<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=446</guid>
		<description><![CDATA[An introduction to send email using the commons email API. This facade to the java mail API should reduce the time you spend writing code that sends out emails.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fcommons-email%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fcommons-email%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are many apache commons projects out there that save your time either directly or indirectly. Some of the well known commons projects are</p>
<ul>
<li>Commons beanutils &#8211; Services wrapped around java beans.</li>
</ul>
<ul>
<li> Commons digester &#8211; XML to java mappings</li>
</ul>
<ul>
<li> Commons lang &#8211; Helper utilities for the java.lang API</li>
</ul>
<ul>
<li> Commons logging &#8211; A generic logging implementation</li>
</ul>
<p>There are other commons implementations that can save your time, but you are probably not using them. One of them is commons email. Commons email provides a facade to the underlying java mail services that come from mail.jar. Sending an email using mail.jar is not that difficult, but when you use commons email it is downright simple</p>
<p>Check out a sample program that sends a simple email</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">SimpleEmail email <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
email.<span style="color: #006633;">setHostName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mail.myserver.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
email.<span style="color: #006633;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jdoe@somewhere.org&quot;</span>, <span style="color: #0000ff;">&quot;John Doe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
email.<span style="color: #006633;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;me@apache.org&quot;</span>, <span style="color: #0000ff;">&quot;Me&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
email.<span style="color: #006633;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
email.<span style="color: #006633;">setMsg</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;This is a simple test of commons-email&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
email.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Thats it. Use the HTMLEmail class to send HTML based emails. You can read more about the commons email API from their <a href="http://commons.apache.org/email/userguide.html" target="_blank">user guide</a>. The project is active and should simplify the parts of your application that send email.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fcommons-email%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fcommons-email%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2009/11/commons-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

