我想通過grails郵件插件發送郵件。我根據文檔進行了配置,並且還關注了幾篇博文(http://blog.lourish.com/2010/04/02/sending-asynchronous-html-email-in-grails-with-activemq-jms-and-gmail/)。那篇文章提到聲明配置的關閉方式覆蓋了其他方法,但並非如此。無論如何,我嘗試了兩種方法,但似乎端口仍然使用默認的smtp。我得到下面的例外。Grails郵件端口配置
exception: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect
現在,我寫了一個小程序直接使用Java郵件庫,我可以發送郵件。配置如下所示。試圖附加配置「mail.smtp.port」:「465」」,但沒有改變..使用上述博客文章中提到的參數,提前同
grails {
mail {
host = "smtp.gmail.com"
port = "465"
username = "[email protected]"
password = "mypwd"
props = ["mail.smtp.auth":"true",
// "mail.smtp.port":"465",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
感謝..
更新結果:它不是端口或防火牆配置,因爲當我從零開始編寫一個grails應用程序,並嘗試使用相同的配置,一切正常。另外,在grails論壇http://grails.1312388.n4.nabble.com/grails-mail-mailSender-does-not-have-config-values-td2237704.html#a2237704。希望得到一個領先的嘗試。
我在一個項目上工作的其他一天,類似的問題的工作。最後,我們發現這是一個防火牆問題,而且應用程序實際上是在嘗試發送替代端口。對於我們來說,例外是給出了關於25號港口的誤導性消息。我不記得具體的細節,因爲它是深夜,我只想回家! :-)祝你好運 – tinny 2010-05-31 10:09:18
哇!這使得它很難..但是,我關閉了防火牆,正如我所說的,具有上述相同配置的純java郵件程序工作正常:-( – bsr 2010-05-31 13:59:30