我使用下面的配置通过播放应用发送电子邮件:
smtp.mock=false
smtp {
host="smtp.mail.yahoo.com"
port="465"
ssl=true
user="pari.test@yahoo.com"
password="XXXXXXXXXXX"
from="pari.test@yahoo.com"
}
代码一切正常。但是,我收到了警告:
smtp is deprecated, use play.mailer instead.
当我使用play.mailer配置代码失败时。 的配置
play.mailer {
host="smtp.mail.yahoo.com"
port=465
ssl=yes
tls=no
user="pari.test@yahoo.com"
password="XXXXXX"
debug=no
timeout=60
connectiontimeout=60
mock=false
}
错误:
[error] application - error sending email
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.mail.yahoo.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
at org.apache.commons.mail.Email.send(Email.java:1448)
at play.api.libs.mailer.SMTPMailer$$anon$2.send(MailerPlugin.scala:100)
at play.api.libs.mailer.CommonsMailer.send(MailerPlugin.scala:130)
at play.api.libs.mailer.SMTPMailer.send(MailerPlugin.scala:110)
at play.api.libs.mailer.SMTPDynamicMailer.send(MailerPlugin.scala:117)
at utils.Mailer.sendEmail(Mailer.scala:30)
at utils.Mailer$$anonfun$sendEmailAsync$1.apply$mcV$sp(Mailer.scala:22)
at utils.Mailer$$anonfun$sendEmailAsync$1.apply(Mailer.scala:22)
at utils.Mailer$$anonfun$sendEmailAsync$1.apply(Mailer.scala:22)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.mail.yahoo.com, port: 465
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
at org.apache.commons.mail.Email.send(Email.java:1448)
at play.api.libs.mailer.SMTPMailer$$anon$2.send(MailerPlugin.scala:100)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:211)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927
源代码位于https://github.com/pariksheet/dribble。
谢谢Pari
答案 0 :(得分:0)
您需要的所有:修改60(s) - > 60000(ms)
play.mailer {
host (mandatory)
port (defaults to 25)
ssl (defaults to no)
tls (defaults to no)
user (optional)
password (optional)
debug (defaults to no, to take effect you also need to set the log level to "DEBUG" for the application logger)
timeout (defaults to 60s in milliseconds)
connectiontimeout (defaults to 60s in milliseconds)
mock (defaults to no, will only log all the email properties instead of sending an email)
}