score:1
Accepted answer
I need to pass Authentication to the session which is what i am missed, Below code worked for me :
val sparkConf = new SparkConf().setAppName("E-mail Alert").setMaster("local")
val sc = new SparkContext(sparkConf)
var bodyText = "Test mail"
val username = "*****************"
val password = "************************"
val smtpHost = "email-smtp.us-east-1.amazonaws.com"
// Set up the mail object
val properties = System.getProperties
properties.put("mail.smtp.host", smtpHost)
properties.put("mail.smtp.user", username);
properties.put("mail.smtp.password", password);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "587")
properties.put("mail.smtp.starttls.enable", "true");
val auth:Authenticator = new Authenticator() {
override def getPasswordAuthentication = new
PasswordAuthentication(username, password)
}
val session = Session.getInstance(properties,auth)
val message = new MimeMessage(session)
// Set the from, to, subject, body text
message.setFrom(new InternetAddress("no-reply@*****.com"))
message.setRecipients(Message.RecipientType.TO, "ajayv@****.com")
message.setSubject("Count of DeviceIDs we are sent daily")
message.setText(bodyText)
// And send it
Transport.send(message)
score:1
Get rid of the Authenticator (which isn't being used at all) and the mail.smtp.user
, mail.smtp.password
, and mail.smtp.auth
properties, then call the Transport.send method that takes a user name and password. If it still doesn't work, post the JavaMail debug output.
Source: stackoverflow.com
Related Query
- Error Retrieving Mail from Gmail with JavaMail + Scala
- Redirect output of unit function/method in scala as standard in for linux mail command
- Scala Play 2.4.x handling extended characters through anorm (MySQL) to Java Mail
- scala Play! object persistence is not a member of package javax
- PlayFramework Scala dependency Injection Javax
- object mail is not a member of package views.html error in IntelliJ Scala
- How can I convert a mail address to a hash in scala
- ADAL4J javax mail parse exception when trying to connect to Azure SQL DB from Spark Submit
- Sending a Mail to Gmail in scala playframework(2.6) slick
- Send a mail with exchange server without using SMTP in scala or java
- Is the Scala 2.8 collections library a case of "the longest suicide note in history"?
- Difference between object and class in Scala
- Scala vs. Groovy vs. Clojure
- Where does Scala look for implicits?
- Scala list concatenation, ::: vs ++
- What is the formal difference in Scala between braces and parentheses, and when should they be used?
- Difference between a Seq and a List in Scala
- Understanding implicit in Scala
- What are Scala context and view bounds?
- Difference between method and function in Scala
- Scala Programming for Android
- Appending an element to the end of a list in Scala
- Case objects vs Enumerations in Scala
- Scala 2.8 breakOut
- difference between foldLeft and reduceLeft in Scala
- What do <:<, <%<, and =:= mean in Scala 2.8, and where are they documented?
- Spark performance for Scala vs Python
- What Scala web-frameworks are available?
- Scala equivalent of Java java.lang.Class<T> Object
- Logging in Scala
More Query from same tag
- scala play json custom validation oneOf
- Duplicate mappings when building docker package using sbt-native-packager
- too many arguments for constructor MyWebSocketActor in Play 2.5.x and Akka 2.4.7
- Add FQDN to log messages in SLF4J/Logback
- Akka Circuit Breaker sharing between actors
- How to run external process in Scala and get both exit code and output?
- Run specs2 in sbt console
- Understanding Scala default argument message
- How to produce nicely formatted XML in Scala?
- How can I extract shared Scala enum logic into a trait or superclass?
- Run gatling project from an executable jar
- Play Json throws exception when field is not populated
- How to implement equals and hashCode proper in scala
- Mapping a list to HTML and intercalating the result in Play 2.0 template
- Test for table/view existence with Scalaquery & create if not present
- Scala test issues
- Scala: Json representation of an ArrayBuffer/ArrayList ... how to avoid printing out empty information in the collection?
- Future yielding with flatMap
- Akka Kafka Custom Serializer
- Tail Recurson without Await
- How to fastly execute mysql query in spark scala
- Scala: type mismatch; found : Unit required: Boolean
- Scala: Generic solution to implicitly convert pairs of case classes
- Sbt project loading error - "java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter"
- Scala lambda in function args
- How to make Slick respect DB column defaults on insert?
- What's wrong with \W on non UTF-8 encodings using Scala?
- Getting a raw string back for use in Javascript in Play Framework 2.0
- Abstract classes, why can't we declare private val and var class member?
- How to update Mongodb structure from string to object?