JavaMail如何通过sina企业邮箱进行发送邮件? 通过sina的免费邮箱完全可以正常发送,不知道为什么,谁可以帮我下!万分感谢!
下面是我的代码:
smtpAuth.getuserinfo("email@", "******");
Properties props = System.getProperties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", "");
Session session = Session.getInstance(props, smtpAuth);
Message msg = new MimeMessage(session);
msg.setDataHandler(new DataHandler(body,"text/html; charset=gb2312"));
msg.setFrom(new InternetAddress("email@","yangqr"));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to,
false));
Transport t = session.getTransport("smtp");
t.connect("", "email@", "******");
msg.setSubject(MimeUtility.encodeText(subject, "gb2312", "b"));
msg.setSentDate(new Date());
msg.setContent(body, "text/html; charset=GBK");
Transport.send(msg);
以下是控制台输出的信息:
DEBUG: setDebug: JavaMail version 1.3.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "", port 25
220 mail5-203. ESMTP
DEBUG SMTP: connected to host "", port: 25
EHLO yangqing-132788
250-mail5-203.
250-8BITMIME
250-SIZE 31457280
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "SIZE", arg "31457280"
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
ZW1haWxAbWxlZS5jb20uY24=
334 UGFzc3dvcmQ6
MTIzNDU2
535 #5.7.0 Authentication failed
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "", port 25
220 mail5-201. ESMTP
DEBUG SMTP: connected to host "", port: 25
EHLO yangqing-132788
250-mail5-201.
250-8BITMIME
250-SIZE 31457280
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "SIZE", arg "31457280"
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
ZW1haWxAbWxlZS5jb20uY24=
334 UGFzc3dvcmQ6
MTIzNDU2
535 #5.7.0 Authentication failed
如果觉得《java发邮件新浪_JavaMail如何通过sina企业邮箱进行发送邮件?》对你有帮助,请点赞、收藏,并留下你的观点哦!