﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-sky</title><link>http://www.blogjava.net/skiyra/</link><description>道，可道，名，可名。</description><language>zh-cn</language><lastBuildDate>Thu, 07 May 2026 00:46:48 GMT</lastBuildDate><pubDate>Thu, 07 May 2026 00:46:48 GMT</pubDate><ttl>60</ttl><item><title>java Email</title><link>http://www.blogjava.net/skiyra/archive/2012/05/15/JavaEmail.html</link><dc:creator>skiyra</dc:creator><author>skiyra</author><pubDate>Tue, 15 May 2012 12:44:00 GMT</pubDate><guid>http://www.blogjava.net/skiyra/archive/2012/05/15/JavaEmail.html</guid><wfw:comment>http://www.blogjava.net/skiyra/comments/378214.html</wfw:comment><comments>http://www.blogjava.net/skiyra/archive/2012/05/15/JavaEmail.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/skiyra/comments/commentRss/378214.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/skiyra/services/trackbacks/378214.html</trackback:ping><description><![CDATA[<div>public class SendMail {</div>
<div></div>
<div><span style="white-space:pre">	</span></div>
<div><span style="white-space:pre">	</span>public static void main(String[] args) {</div>
<div><span style="white-space:pre"> </span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; try {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Properties p = new Properties(); //Properties p = System.getProperties(); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p.put("mail.smtp.auth", "true"); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p.put("mail.transport.protocol", "smtp"); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p.put("mail.smtp.host", "smtp.163.com"); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p.put("mail.smtp.port", "25"); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //建立会话 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session session = Session.getInstance(p); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message msg = new MimeMessage(session); //建立信息 &nbsp;</div>
<div>&nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.setFrom(new InternetAddress("skiyra@163.com")); //发件人 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.setRecipient(Message.RecipientType.TO, new InternetAddress("myb4562@163.com")); //收件人 &nbsp;</div>
<div>&nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.setSentDate(new Date()); // 发送日期 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.setSubject("答话稀有"); // 主题 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.setText("快点下在"); //内容 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 邮件服务器进行验证 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Transport tran = session.getTransport("smtp"); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tran.connect("smtp.163.com", "skiyra", "aaaaaaaaaaaa"); &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // bluebit_cn是用户名，xiaohao是密码 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tran.sendMessage(msg, msg.getAllRecipients()); // 发送 &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("邮件发送成功"); &nbsp;</div>
<div><span style="white-space:pre"> </span></div>
<div><span style="white-space:pre"> </span></div>
<div><span style="white-space:pre"> </span>} catch (AddressException e) {</div>
<div><span style="white-space:pre"> </span>e.printStackTrace();</div>
<div><span style="white-space:pre"> </span>} catch (MessagingException e) {</div>
<div><span style="white-space:pre"> </span>e.printStackTrace();</div>
<div><span style="white-space:pre"> </span>} //发件人 &nbsp;</div>
<div>&nbsp;</div>
<div><span style="white-space:pre">	</span>}</div>
<div><span style="white-space:pre">	</span></div>
<div>}</div>
<div></div><img src ="http://www.blogjava.net/skiyra/aggbug/378214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/skiyra/" target="_blank">skiyra</a> 2012-05-15 20:44 <a href="http://www.blogjava.net/skiyra/archive/2012/05/15/JavaEmail.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>