开发者

grails mail connection refused

it seems i have tried the mail config in the way that its docs said, but still i get:

Error 500: Executing action [x] of controller [x] caused exception: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP 

I am using google apps for my email - me@dogself.com is using gmail. i cannot get grails to send out a test message on my dev box (win 7).

my config is:

   host = "smtp.gmail.com"
   port = 465
   username = "autoresponse@dogself.com"
   password = "x"
   props = ["mail.smtp.auth":"true",
            "mail.smtp.debug":"true",
            "mail.smtp.starttl开发者_开发百科s.enable":"true",
            "mail.smtp.socketFactory.port":"465",
            "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
            "mail.smtp.socketFactory.fallback":"false"]

edit: do i need to have some sort of a signed key to support ssl connection to gmail?


Try the following:

props = ["mail.transport.protocol":"smtps",
         "mail.smtps.host":"smtp.gmail.com",
         "mail.smtps.port":"465",
         "mail.smtps.auth":"true"]

That seems to be the standard set of params necessary to connect to Google's SMTP server. The key thing is to use smtps instead of smtp plus TLS.


Switch to using the Grails Mail Plugin and give it another try. There is a sample configuration for Gmail near the end of that web page.


What happens if you remove:

mail.smtp.starttls.enable: "true"

I've gotten mine to work without that.


You have two conflicting properties in your "props" declaration:

"mail.smtp.starttls.enable":"true" is used for a plaintext handshake with the server, and then starts TLS encryption negotiations with the server.

"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory" requires an encrypted handshake.

The port you specified (465) could work with either, but is normally for encrypted use. If the server supports it, I would suggest using the first property "mail.smtp.starttls.enable":"true" and augment it with "mail.smtp.starttls.required":"true" to ensure that your messages are encrypted between your application and the SMTP server, and remove the "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜