圣杯项目。我使用电子邮件插件并在尝试调用方法“sendMail”时出现异常
错误:
Caused by: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp. Failed messages: javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp; message exceptions (1) are:
Failed message 1: javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp
配置.groovy
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "mymail@gmail.com"
password = "mypass"
props = ["mail.smtp.auth":"true",
//"mail.smtp.port":"465",
//"mail.debug":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
发送示例
sendMail {
to "fred@gmail.com"
subject "Hello Fred"
body 'How are you?'
}
我究竟做错了什么?