0
我在閱讀關於通過播放框架(java)發送電子郵件的最佳方式。我發現這個:https://github.com/playframework/play-mailer,我按照說明操作。我使用Gmail。java播放框架中的gmail smtp異常
這是我加入application.conf:
play.mailer.host="smtp.gmail.com"
play.mailer.port=587
play.mailer.ssl=yes
play.mailer.tls=no
play.mailer.user="[email protected]"
play.mailer.password="blabla"
,這裏是我的控制器:
Email email = new Email();
email.setSubject("Confirmation");
email.setFrom("Mister FROM <[email protected]>");
email.addTo("Miss TO <[email protected]>");
email.setBodyText("A text message");
email.setBodyHtml("<html><body><p>An <b>html</b> message</p></body></html>");
mailerClient.send(email);
一切都沒有問題,編譯,但是當我運行它,我得到這個異常:
[EmailException: Sending the email to the following server failed : smtp.gmail.com:587] at mailerClient.send(email);
我啓用了IMAP,因爲它之前被禁用。但仍然發生山姆異常。 – xpg94
使用java郵件API而不是這個。 http://www.javatpoint.com/example-of-sending-email-using-java-mail-api https://www.arclab.com/en/kb/email/list-of-smtp-and -imap-servers-mailserver-list.html – Samir
我設法使用apache commons發送郵件,它使用java郵件API。謝謝 – xpg94