1. Configure the email plugin to be configured in the Config.groovy file:
Plugins { compile ": mail:1.0.5" }
2. Configure the Config.groovy file:
Grails { Mail { host = "smtp.163.com" //Outgoing mail server username = "[email protected]" //Email Mailbox Password = "**********" //email password props = ["Mail.smtp.auth": "true"] //Set SMTP identity authentication }}
Note: 163 mailbox When you set up password, you should be aware of the settings-mailbox Settings-Client authorization password, whether it is turned on. Do not open password fill in the email password, open to fill in the authorization password.
3. Send email:
SendMail { Async false from "[email protected]" ///Sender mailbox (consistent with username in Config.groovy file) to @163.com //Receiver mailbox subject "Send Message subject" body " Send mail message body" }
Note: Send the mailbox to open the Pop3/smtp/imap service.
Grails Email Send mail plugin