概述
我正在经历这个
Link并试图执行代码.
总结同样如下:
private static final String SSL_FACTORY = "SendMailDemoSSLSocketFactory"; //SendMailDemoSSLSocketFactory extends SSLSocketFactory
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.submitter", emailUsername);
props.put("mail.smtp.user", emailUsername);
props.put("mail.smtp.host", smtpHostName);
props.put("mail.debug", debug);
props.put("mail.smtp.port", smtpPort);
props.put("mail.smtp.ssl.socketFactory.port", smtpPort);
props.put("mail.smtp.ssl.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.starttls.enable", "true");
props.setProperty("mail.smtps.ssl.enable", "true");
props.put("mail.transport.protocol", "smtps");
props.put("mail.smtp.ssl.trust", smtpHostName);
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(emailUsername,
emailPassword);
}
});
session.setDebug(Boolean.parseBoolean(debug));
Message msg = new MimeMessage(session);
//set message
SMTPSSLTransport transport = (SMTPSSLTransport) session
.getTransport("smtps");
transport.connect(smtpHostName, new Integer(smtpPort).intValue(),
emailUsername, emailPassword);
msg.saveChanges();
transport.sendMessage(msg, msg.getAllRecipients());
与此相同,我能够成功连接,但身份验证不成功.我无法找到代码出错的地方.
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: C:Program FilesJavajdk1.7.0_25jrelibjavamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: successfully loaded file: C:Program FilesJavajdk1.7.0_25jrelibjavamail.address.map
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL true
220 smtp.gmail.com ESMTP xv9sm19052844pbc.2 - gsmtp
DEBUG SMTP: connected to host "smtp.gmail.com", port: 465
EHLO test
250-smtp.gmail.com at your service, [182.64.100.170]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
DEBUG SMTP: use8bit false
邮件来自:
530-5.5.1需要验证.了解更多信息
530 5.5.1 https://support.google.com/mail/answer/14257 xv9sm19052844pbc.2 – gsmtp
com.sun.mail.smtp.SMTPSendFailedException:530-5.5.1需要验证.在530 5.5.1 https://support.google.com/mail/answer/14257 xv9sm19052844pbc.2 – gsmtp了解更多信息
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at edu.bhavesh.mail.smtp.ssl.SendMailDemo.sendSSLMessage(SendMailDemo.java:135)
at edu.bhavesh.mail.smtp.ssl.SendMailDemo.main(SendMailDemo.java:41)
com.sun.mail.smtp.SMTPSendFailedException:530-5.5.1需要验证.了解更多信息
530 5.5.1 https://support.google.com/mail/answer/14257 xv9sm19052844pbc.2 – gsmtp
放弃
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at edu.bhavesh.mail.smtp.ssl.SendMailDemo.sendSSLMessage(SendMailDemo.java:135)
at edu.bhavesh.mail.smtp.ssl.SendMailDemo.main(SendMailDemo.java:41)
221 2.0.0 closing connection xv9sm19052844pbc.2 - gsmtp
最后
以上就是开朗金针菇为你收集整理的java 接收邮件ssl,Java SSL电子邮件错误的全部内容,希望文章能够帮你解决java 接收邮件ssl,Java SSL电子邮件错误所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复