Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.{Date, Properties}
- import javax.mail._
- import javax.mail.internet._
- val host = "smtp.gmail.com"
- val username = "your_mail_address at gmail.com"
- val password = "your_password"
- val props: Properties = System.getProperties
- props.put("mail.smtps.auth", "true")
- val session: Session = Session.getInstance(props, null)
- val msg = new MimeMessage(session)
- msg.setRecipients(Message.RecipientType.TO,
- "recipient at gmail.com")
- msg.setSubject("From Scala To You!")
- msg.setSentDate(new Date)
- msg.setText("すから!!\n")
- val t: Transport = session.getTransport("smtps")
- try {
- t.connect(host, username, password)
- t.sendMessage(msg, msg.getAllRecipients)
- } finally {
- t.close()
- }
Add Comment
Please, Sign In to add comment