3

Below, I have pasted my code for sending mail with attached file. I don't what I missed in my code but I am getting a NoSuchElementException in my web application. Can anyone tell what I am missing or is there a problem with the server part? Do I have to add apache or any server licence in my code project.

Below is my code:

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"

Exception:

! @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]
Peter Neyens
  • 9,770
  • 27
  • 33
Vicky
  • 921
  • 1
  • 11
  • 33

2 Answers2

0

Looks like wrong configuration. Have you configured

1500:play.api.libs.mailer.CommonsMailerPlugin 

in your conf/play.plugins?

Nyavro
  • 8,806
  • 2
  • 26
  • 33
0

This all happens because we are using an outdated version of the plugin. See @Bhavya's comment

Latest version of the plugin is here: https://github.com/playframework/play-mailer

Blackbird
  • 2,368
  • 4
  • 26
  • 41