<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: mail code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 15 Oct 2008 16:01:55 GMT</pubDate>
    <description>DZone Snippets: mail code</description>
    <item>
      <title>Sending Mail</title>
      <link>http://snippets.dzone.com/posts/show/96</link>
      <description>This code requires JavaMail.  Specifically it requires mailapi.jar and smtp.jar from the JavaMail distribution (available at http://java.sun.com/) as well as activation.jar from the JavaBeans Activation Framework (available at http://java.sun.com/beans/glasgow/jaf.html).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Properties props = new Properties();&lt;br /&gt;props.put("mail.smtp.host", "your-smtp-host.com");&lt;br /&gt;Session session = Session.getDefaultInstance(props, null);&lt;br /&gt;&lt;br /&gt;MimeMessage msg = new MimeMessage(session);&lt;br /&gt;msg.setFrom(new InternetAddress(from));&lt;br /&gt;msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(to));&lt;br /&gt;msg.setSubject(subject);&lt;br /&gt;msg.setSentDate(new Date());&lt;br /&gt;msg.setContent(message, "text/plain");&lt;br /&gt;&lt;br /&gt;Transport.send(msg);&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 09 Apr 2005 05:13:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/96</guid>
      <author>aeden (Anthony Eden)</author>
    </item>
  </channel>
</rss>
