email - 从Grails服务器使用authsmtp

标签 email grails authsmtp

这是一个非常具体的问题,在grails nabble论坛上我没有运气,所以我想我会在这里发布。我正在使用grails邮件插件,但是我认为我的问题是关于将authsmtp用作来自服务器的电子邮件网关的一般性问题。

我无法使用authsmtp从我的应用程序发送邮件。我已经安装并配置了邮件插件,最初是使用ISP的SMTP服务器发送邮件的。但是,当我部署到AWS EC2时,这失败了,因为SMTP主机阻止了我的 flex IP。因此,我为自己购买了一个authsmtp帐户,并将我的服务器电子邮件地址设置为authsmtp上的接受电子邮件地址。

然后,我在SecurityConfig.groovy中更改了配置,以指向已被指定的authsmtp服务器。

   mailHost = "mail.authsmtp.com"
   mailUsername = "myusername"
   mailPassword = "mypassword"
   mailProtocol = "smtp"
   mailFrom = "valid-authsmtp-address@mydomain.com"
   mailPort = 2525

...而我只是想让它在本地部署,然后再部署回AWS。发送邮件失败,在我的日志中,我遇到以下异常:
2010-02-13 10:59:44,218 [http-8080-1] ERROR service.EmailerService  - Failed to send emails: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 513 5.0.0 Your email system must authenticate before sending mail.

org.springframework.mail.MailSendException; nested exception details (1) are:
Failed message 1:
com.sun.mail.smtp.SMTPSendFailedException: 513 5.0.0 Your email system must authenticate before sending mail. at
com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
       at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
       at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)

自从我在
配置绝对正确。

使用authsmtp支持进行简短但不太有用的对话表明
在发送之前,我需要MD5和/或base64编码我的凭据,所以我
问题分为三个部分...

1)知道失败是怎么回事以及为什么该消息是
出现?
2)我将如何编码凭据以传递给authsmtp以及我将如何
为邮件插件配置
3)是否有任何人成功连接并通过authsmtp从
邮件插件,特别是来自AWS EC2的插件?

最佳答案

使用Acegi插件发送电子邮件时,在后台使用Spring JavaMailSenderImpl。查看其docs:

Note that the underlying JavaMail Session has to be configured with the property "mail.smtp.auth" set to true, else the specified password will not be sent to the mail server by the JavaMail runtime. If you are not explicitly passing in a Session to use, simply specify this setting via setJavaMailProperties(java.util.Properties).



因此,将以下内容附加到SecurityConfig.groovy:
javaMailProperties = [ "mail.smtp.auth": true]

关于email - 从Grails服务器使用authsmtp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2310339/

相关文章:

Grails 3.2 Resource Bundle 不显示具有正确编码的文本

spring - Tomcat/Spring 不再使用身份验证将电子邮件发送到 SMTP 服务器

php - 电子邮件内容中单词内的随机空格

windows - 适用于 Windows 开发的最简单的免费电子邮件服务器

IOS后台发邮件

c# - 通过网络服务生成 PDF 并将其作为附件通过电子邮件发送

html - 在grails中显示blob文本

grails - BuildConfig.groovy和Config.groovy有什么区别?