gpt4 book ai didi

grails - Grails 中的电子邮件验证

转载 作者:行者123 更新时间:2023-12-02 08:39:38 26 4
gpt4 key购买 nike

我是 grails 新手,正在使用 grails 开发 Web 应用程序。

在我的注册页面中,我正在获取用户的电子邮件 ID,并且我需要发送一封包含身份验证链接的邮件。

http://grails.org/plugin/mail

http://grails.org/plugin/email-confirmation

我已经引用了这些页面和许多其他页面来完成此任务。 但问题是,我的电子邮件没有发送。

我用过

Gmail SMTP server address : smtp.gmail.com
Gmail SMTP username : myid@gmail.com
Gmail SMTP password : -my password-
Gmail SMTP port : 465
Gmail SMTP TLS/SSL required : yes

邮件设置为:

grails { 
mail {
host = "smtp.gmail.com"
port = 465
username = "myId@gmail.com"
password = "mypassword"
props = [
"mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
grails.mail.default.from="noreply@gmail.com"

但至少

sendMail {     
to "friend@gmail.com"
subject "Hello "
body 'How are you?'
}

不工作。

发生的异常是

Error 500: Internal Server Error

URI
/MailVerificationDemo/user/signup/form
Class
java.net.ConnectException
Message
Connection refused

Around line 104 of MailMessageBuilder.groovy

101: log.trace("Sending mail ${getDescription(message)}} ...")102: }103:104: mailSender.send(message instanceof MimeMailMessage ? message.mimeMessage : message)105:106: if (log.traceEnabled) {107: log.trace("Sent mail ${getDescription(message)}} ...")

Around line 41 of grails-app/services/grails/plugin/mail/MailService.groovy

38: callable.resolveStrategy = Closure.DELEGATE_FIRST39: callable.call()40:41: messageBuilder.sendMessage()42: }43:44: def getMailConfig() {

Around line 18 of grails-app/controllers/user/UserController.groovy

15: return16: }17:18: mailService.sendMail {19: to userInstance.email20: subject "New User Confirmation"21: html g.render(template:"mailtemplate",model:[code:userInstance.confirmCode])

Around line 195 of PageFragmentCachingFilter.java

192: if (CollectionUtils.isEmpty(cacheOperations)) {193: log.debug("No cacheable annotation found for {}:{} {}",194: new Object[] { request.getMethod(), request.getRequestURI(), getContext() });195: chain.doFilter(request, response);196: return;197: }198:

Around line 63 of AbstractFilter.java

60: try {61: // NO_FILTER set for RequestDispatcher forwards to avoid double gzipping62: if (filterNotDisabled(request)) {63: doFilter(request, response, chain);64: }65: else {66: chain.doFilter(req, res);

this is the exception

最佳答案

试试这个,它对我有用。请注意:需要 Gmail SMTP TLS/SSL:是。但是你没有输入 "mail.smtp.starttls.enable": "true"

grails.mail.host="smtp.gmail.com"
grails.mail.port=587
grails.mail.username="yourUsernameHere"
grails.mail.password="yourPwdHere"
grails.mail.from="defaultMailFromHere"
grails.mail.props = ['mail.smtp.auth': "true",
"mail.smtp.starttls.enable": "true",
"mail.from":"defaultMailFromHere"]
grails.mail.javaMailProperties = ['mail.smtp.auth': "true",
"mail.smtp.starttls.enable": "true",
"mail.from":"defaultMailFromHere"]

关于grails - Grails 中的电子邮件验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22342493/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com