0
 try {
        Email email = new SimpleEmail();
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(587);
        email.setAuthenticator(new DefaultAuthenticator("***@gmail.com", "*********"));
        email.setSSL(true);
        email.setFrom("*******@gmail.com");
        email.setSubject("TestMail");
        email.setMsg("This is a test mail ... :-)");
        email.addTo("*****@gmail.com");
        email.setTLS(true);
        email.send();
    } catch (Exception e) {
        e.printStackTrace();
    }

これは私が使用したコードで、これは印刷スタック トレースです。

org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:587
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
    at org.apache.commons.mail.Email.send(Email.java:1267)
    at Main.main(Main.java:28)
Caused by: javax.mail.AuthenticationFailedException
    at javax.mail.Service.connect(Service.java:306)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at javax.mail.Transport.send0(Transport.java:168)
    at javax.mail.Transport.send(Transport.java:98)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)

誰かが私のコードの何が問題なのか教えてもらえますか??

4

1 に答える 1

0

ポート465を試してみましたか?

そしてemail.setSSLOnConnect(true); setSSLとsetTLSの代わりに?

于 2012-04-26T18:18:11.183 に答える