1.配置email插件,在Config.groovy文件中配置:

plugins {
        compile ":mail:1.0.5"
    }

 2.配置Config.groovy文件:

grails {
    mail {
        host = "smtp.163.com"   //发送邮件服务器
        username = "xxx@163.com"   //发送邮件邮箱
        password = "**********"  //发送邮件邮箱密码
        props = ["mail.smtp.auth":"true"]  //设置smtp的身份认证
    }
}

注:163邮箱在设置password时,应注意设置—邮箱设置—客户端授权密码,是否开启。未开启password填写邮箱密码,开启填写授权密码。

3.发送邮箱:

sendMail {
                async false
                from "xxx@163.com"  //发送方邮箱 (与Config.groovy文件中的username一致)
                to   *****@163.com   //接收方邮箱
                subject  "发送邮件主题"
                body  "发送邮件消息体"
            }

 注:发送邮箱要开启POP3/SMTP/IMAP服务。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2021-12-19
  • 2021-05-19
  • 2021-07-03
  • 2022-01-13
  • 2021-06-08
相关资源
相似解决方案