2008-04-25
java mail
2005年以后注册的用户被锁定了。。。。需要升级。。。
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Test {
/**
* @param args
* @throws MessagingException
*/
public static void main(String[] args) {
try {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.smtp.auth", "true");
Session s = Session.getDefaultInstance(props);
s.setDebug(true);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("wyy_wwc@163.com");
try {
message.setFrom(from);
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InternetAddress[] to = new InternetAddress[1];
to[0] = new InternetAddress("wwc_wyy@163.com");
message.setRecipients(Message.RecipientType.TO, to);
message.setSubject("错误报告" + new Date());
message.setText("how are you");
// message.setContent("how are you", "text/plain");
message.saveChanges();
// 现在的smtp服务器基本都需要smtp验证
Transport transport = s.getTransport("smtp");
transport.connect("smtp.163.com", "wyy_wwc@163.com", "5211314_wyy");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("发送成功!!!");
} catch (Exception e) {
e.printStackTrace();
}
}
}
发表评论
- 浏览: 13338 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
我的相册
2008-6-26
共 122 张
共 122 张
最近加入圈子
最新评论
-
别了,盖茨
我在喝水。。。
-- by 叶子 -
创建XMLHttpRequest对象及 ...
谢谢楼主了....
-- by fp2009 -
结合DWR获取远程URL数据
这样获取远程的东西,其实现在很多公司都在用, 不过都是一些小公司。。。 如果你是 ...
-- by weiweichen1985 -
结合DWR获取远程URL数据
还有,你这样通过url从远程获取的东西,一般什么时候会用到啊? 如果是页面的话, ...
-- by guo_david_wei -
结合DWR获取远程URL数据
伟哥,你的dwr搞的很不错嘛.... 我的那个问题也给解决一下啦... 放那很久 ...
-- by guo_david_wei






评论排行榜