用的是163邮箱,授权已开,在使用JavaMail发邮件,每天开始的几封能正常发送出去,后面会出现以下异常:
源码是:
package test.ceshi; import java.io.File; import java.io.IOException; import java.util.Properties; import javax.mail.Authenticator; import javax.mail.Message.RecipientType; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; public class MailTest { public static void main(String[] args) throws AddressException, MessagingException, IOException { Properties pro = new Properties(); pro.put("mail.smtp.host", "smtp.163.com"); pro.put("mail.smtp.auth", "true"); //pro.setProperty("mail.smtp.starttls.enable", "true"); Authenticator auth = new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("用户名", "授权码"); } }; Session session = Session.getInstance(pro, auth); MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress("我的邮箱")); msg.setRecipients(RecipientType.TO, "发送给的邮箱"); msg.setSubject("我自己的邮件"); msg.setContent("我的邮件正文", "text/html;charset=utf-8"); Transport.send(msg); } }
各种方法都试过了还是解决不了,求大神解答,谢谢!
杨__羊羊
相关分类