Guest User

Untitled

a guest
Jul 20th, 2018
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.util.{Date, Properties}
  2. import javax.mail._
  3. import javax.mail.internet._
  4.  
  5. val host = "smtp.gmail.com"
  6. val username = "your_mail_address at gmail.com"
  7. val password = "your_password"
  8.  
  9. val props: Properties = System.getProperties
  10. props.put("mail.smtps.auth", "true")
  11.  
  12. val session: Session = Session.getInstance(props, null)
  13. val msg = new MimeMessage(session)
  14.  
  15. msg.setRecipients(Message.RecipientType.TO,
  16. "recipient at gmail.com")
  17. msg.setSubject("From Scala To You!")
  18. msg.setSentDate(new Date)
  19. msg.setText("すから!!\n")
  20.  
  21. val t: Transport = session.getTransport("smtps")
  22. try {
  23. t.connect(host, username, password)
  24. t.sendMessage(msg, msg.getAllRecipients)
  25. } finally {
  26. t.close()
  27. }
Add Comment
Please, Sign In to add comment