厚德博学 敬业乐群
@sky
全部博文(252)
2015年(2)
2014年(1)
2013年(1)
2012年(16)
2011年(42)
2010年(67)
2009年(87)
2008年(36)
25742040
shijiulo
niuxlinu
ebayboy
hayand66
大鬼不动
acer1025
醉鬼的故
小雅贝贝
XINGCHEN
wzy_yzw
十的9次
zds05
bjywxc
zlhc1
smile124
cynthia
格伯纳
分类:
2009-06-24 10:15:51
import java.io.*; import java.util.*; import java.net.*; import javax.mail.*; import javax.mail.internet.*; import javax.mail.internet.MimeMultipart; public class readline { public Session CreateSession() throws Exception { Properties prop = new Properties(); prop.setProperty("mail.transport.protocol", "smtp"); prop.setProperty("mail.smtp.auth", "true"); Session session = Session.getInstance(prop); session.setDebug(true); return session; } public void SendMail(Session session) throws Exception { String server = "smtp.163.com"; String user = "ngad@163.com"; String pass = "xxxxx"; String from = "ngad@163.com"; String to = "blues@gmail.com"; String subject = "mailtest"; for (int i = 0; i < 10; i++) { System.out.println(i); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to)); message.setSubject(subject); message.setText("test" + String.valueOf(i)); message.saveChanges(); Transport transport = session.getTransport(); transport.connect(server, user, pass); transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO)); transport.close(); } } public static void main(String args[]) throws Exception { readline t = new readline(); Session session = t.CreateSession(); t.SendMail(session); System.exit(0); } }
上一篇:java复制一个文本文件
下一篇:echo服务器(任意数据)
登录 注册