下面,我粘贴了我的代码,用于发送带附件的邮件。我没有忘记我的代码,但我在我的网络应用程序中得到NoSuchElementException
。任何人都可以告诉我缺少什么或服务器部分有问题吗?我是否必须在代码项目中添加apache或任何服务器许可证。
以下是我的代码:
val email = Email(
"Simple email",
"Mister FROM <vignesh.gopal@hubino.com>",
Seq("Miss TO <ibrahim.sultan@hubino.com>"),
attachments = Seq(
AttachmentFile("leak.txt", new File("E:/oui_mem_leak.txt")),
AttachmentData("data.txt", "data".getBytes, "text/plain", Some("Simple data"), Some(EmailAttachment.INLINE))),
bodyText = Some("A text message"),
bodyHtml = Some("<html><body><p>An <b>html</b> message</p></body></html>")
)
println("email contents: " + email)
MailerPlugin.send(email)
application.conf
smtp.host = localhost
smtp.port = 9000
smtp.ssl = false
smtp.tls = false
smtp.debug = false
smtp.mock = false
build.sbt
"org.apache.commons" % "commons-email" % "1.3.3",
"com.typesafe.play" %% "play-mailer" % "2.4.1"
例外:
! @6nj6i1d36 - Internal server error, for (GET) [/stores/algo/file/download] ->
play.api.Application$$anon$1: Execution exception[[NoSuchElementException: None
get]]
at play.api.Application$class.handleError(Application.scala:296) ~[play
2.11-2.3.9.jar:2.3.9]
at play.api.DefaultApplication.handleError(Application.scala:402) [play
2.11-2.3.9.jar:2.3.9]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonf
n$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.11-2.3.9.ja
:2.3.9]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonf
n$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.11-2.3.9.ja
:2.3.9]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.
cala:36) [scala-library-2.11.6.jar:na]
Caused by: java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:347) ~[scala-library-2.11.6.jar:na]
at scala.None$.get(Option.scala:345) ~[scala-library-2.11.6.jar:na]
at play.api.libs.mailer.MailerPlugin$.send(MailerPlugin.scala:25) ~[pla
-mailer_2.11-2.4.1.jar:2.4.1]
答案 0 :(得分:0)
看起来配置错误。你配置了
Geolocate (with page caching support)
在你的conf / play.plugins?
答案 1 :(得分:0)
这一切都发生了,因为我们使用的是插件的过时版本。见@ Bhavya的评论
该插件的最新版本位于:https://github.com/playframework/play-mailer