gpt4 book ai didi

scala - 将电子邮件发送到以下服务器失败 : smtp. gmail.com:25

转载 作者:行者123 更新时间:2023-12-04 00:09:48 25 4
gpt4 key购买 nike

当我尝试从 Scala Playmework 发送邮件时,出现以下错误,

[ERROR] [10/10/2013 13:31:16.263] [play-akka.actor.default-dispatcher-75] [TaskInvocation] Sending the email to the following server failed : smtp.gmail.com:25
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
at org.apache.commons.mail.Email.send(Email.java:1267)
at com.typesafe.plugin.CommonsMailer.send(MailerPlugin.scala:241)
at com.typesafe.plugin.MailerBuilder$class.sendHtml(MailerPlugin.scala:204)
at com.typesafe.plugin.CommonsMailer.sendHtml(MailerPlugin.scala:215)
at models.SignUpProcess$$anonfun$models$SignUpProcess$$sendEmail$1.apply$mcV$sp(SignUpProcess.scala:261)
at akka.actor.DefaultScheduler$$anon$8.run(Scheduler.scala:193)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:137)
at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
Caused by: javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
... 12 more

如何解决这个错误?

SignUpProcess.scala
private def sendEmail(subject: String, recipient: String, bodyString:Html) {

import scala.concurrent.duration._
import play.api.libs.concurrent.Execution.Implicits._

Akka.system.scheduler.scheduleOnce(1 seconds) {
val mail = use[MailerPlugin].email
mail.setSubject(subject)
mail.addRecipient(recipient)
mail.addFrom("innodeagcm@gmail.com")
println(bodyString)


mail.sendHtml(bodyString.toString)
}
}

application.conf
smtp.host = smtp.gmail.com
smtp.port = 465
smtp.ssl = true
smtp.tls = no
smtp.user = "companymail@gmail.com"
smtp.password = "mypassword"

最佳答案

1. 这是 的工作配置Gmail :

smtp.host=smtp.gmail.com
smtp.port=587
smtp.ssl=yes
smtp.user="me@gmail.com"
smtp.password="myPassword"

您必须使用 端口 587 (因此激活 SSL )

2. 还要确保 两因素身份验证未激活 (否则您必须生成新的应用程序密码)

3. 连接失败的另一个原因:它看起来像是 可疑连接 .

因此,请检查您帐户上从 google 收到的邮件,以确保连接未被 google 阻止(如果游戏托管在另一个国家/地区而不是您用于手动连接的国家/地区,则会发生这种情况)

关于scala - 将电子邮件发送到以下服务器失败 : smtp. gmail.com:25,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19292882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com