SendGrid
addonで有効にする。
https://addons.heroku.com/sendgrid$ heroku config
SENDGRID_PASSWORD:
SENDGRID_USERNAME:
↑パスワードとユーザ名を確認
playframework
playframework のプラグインはこちら。
https://github.com/typesafehub/play-plugins/tree/master/mailer
最新版は下記です。
"com.typesafe" %% "play-plugins-mailer" % "2.2.0"
conf/application.conf
smtp.host=smtp.sendgrid.net
smtp.port=587
smtp.user=[SENDGRID_USERNAME]
smtp.password=[SENDGRID_PASSWORD]
例に習って、以下のようなobjectを作る
import play.api.Play.current
import com.typesafe.plugin._
object Mailer {
def send = {
val mail = use[MailerPlugin].email
mail.setSubject("mailer test")
mail.setRecipient("[宛先メールアドレス]")
mail.setFrom("[送信元メールアドレス]")
mail.send( "text" )
}
}