当前位置:   article > 正文

javamail发送网页邮件,且有中文_javamail发送网页内容

javamail发送网页内容
  1. public void sendMail() throws IOException {
  2. // create some properties and get the default Session
  3. Properties props = new Properties();
  4. props.put("mail.smtp.host", "smtp.sina.com.cn");
  5. props.setProperty("mail.smtp.auth", "true"); //这个必须加上 否则发送不了
  6. UserAuthenticator userAuthenticator = new UserAuthenticator("wyxz126@sina.com", "i5v2y6");
  7. Session session = Session.getInstance(props, userAuthenticator);
  8. session.setDebug(true);
  9. try {
  10. // create a message
  11. MimeMessage msg = new MimeMessage(session);
  12. msg.setFrom(new InternetAddress("wyxz126@sina.com"));
  13. InternetAddress[] address = {new InternetAddress(addressurl)};
  14. msg.setRecipients(Message.RecipientType.TO, address);
  15. msg.setSubject("会员注册成功 - ITeye做最棒的软件开发交流社区");
  16. msg.setSentDate(new Date());
  17. DataHandler data = new DataHandler(msgTextBuffer.toString(),"text/html;charset=gb2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/95420
推荐阅读
  

闽ICP备14008679号