| /* *author:tyfun *datetime:2003.01.09 *package:com.westarsoft.function */ package com.westarsoft.function; import java.util.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class sendmail { private string smtpserver = new string(); private string from = new string(); private string subject = new string(); private string content = new string(); private string user = new string(); private string password = new string(); public string getsmtpserver() { return smtpserver; } public void setsmtpserver(string smtpserver) { this.smtpserver = smtpserver; } public string getfrom() { return from; } public void setfrom(string from) { this.from = from; } public string getsubject() { return subject; } public void setsubject(string subject) { this.subject = subject; } public string getcontent() { return content; } public void setcontent(string content) { this.content = content; } public string getuser() { return user; } public void setuser(string user) { this.user = user; } public string getpassword() { return password; } public void setpassword(string password) { this.password = password; } public void sendmailto(string to) { try { properties props = new properties(); session sendmailsession; store store; transport transport; sendmailsession = session.getinstance(props, null); props.put("mail.smtp.host", smtpserver); mimemessage newmessage = new mimemessage(sendmailsession); newmessage.setfrom(new internetaddress(from)); newmessage.setsubject(subject); newmessage.setsentdate(new date()); newmessage.settext(content); stringtokenizer token = new stringtokenizer(to, ","); internetaddress[] addrarr = new internetaddress[token.counttokens()]; int i = 0; while(token.hasmoretokens()) { addrarr[i] = new internetaddress(token.nexttoken().tostring()); i++; } transport = sendmailsession.gettransport("smtp"); transport.connect(smtpserver, user, password); newmessage.setrecipients(message.recipienttype.to, addrarr); transport.send(newmessage); } catch(exception e) { system.out.println(e); } } /* public static void main(string[] args) { sendmail mail = new sendmail(); mail.setsmtpserver("200.1.1.157"); mail.setuser("lint"); mail.setpassword("30320"); mail.setfrom("[email protected]"); mail.setsubject("测试"); mail.setcontent("test"); mail.sendmailto("[email protected],[email protected],[email protected]"); } */ } |
商业源码热门下载www.html.org.cn
新闻热点
疑难解答
图片精选