开发者

Using authsmtp from a Grails server

This is quite a specific question, and I have had no luck on the grails nabble forum, so I thought I would post here. I am using the grails mail plug-in, but I think my question is a general one about using authsmtp as an email gateway from my server.

I am having trouble sending mail from my app using authsmtp. I have installed and configured the mail plugin and was originally using my ISP's SMTP server to send mails. However when I deployed to AWS EC2 this failed because my elastic IP was blocked by the SMTP host. So I bought myself an authsmtp account and set up my server email address as an accepted one at authsmtp.

I then changed my configuration in SecurityConfig.groovy to point to the authsmtp server that I had been designated...

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

...and I'm just trying to get this to work locally before I deploy back up to AWS. Sending mail fails and in my log I have this exception:

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开发者_JS百科 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)

I'm a bit lost since the username and password I provide in the configuration are definitely correct.

A terse and not very helpful conversation with authsmtp support suggests that I need to MD5 and/or base64 encode my credentials before sending, so my question is in three parts...

1) any idea what's going on with the failure and why that message is appearing? 2) how would I encode the credentials to pass to authsmtp and how would I configure that for the mail plugin 3) has anyone successfully connected and sent mail through authsmtp from the mail plugin and specifically from AWS EC2?


When sending Email using the Acegi plugin, under the hood a Spring JavaMailSenderImpl is used. Looking at its 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).

So append to your SecurityConfig.groovy the following:

javaMailProperties = [ "mail.smtp.auth": true]


I didn't find a solution to this using the Grails mail plugin, so I'm still interested in an answer, however I did find a workround. It may be useful in case anyone else follows me down this lonely path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜