在Java Web应用程序中使用Gmail作为SMTP服务器速度很慢 [英] Using gmail as SMTP server in Java web app is slow

查看:142
本文介绍了在Java Web应用程序中使用Gmail作为SMTP服务器速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人能够向我解释为什么每次我的Java Web应用程序使用Gmail的SMTP服务器发送电子邮件时,这需要将近30秒?查看以下时间戳:



13/04 / 2010-22:24:27:281 DEBUG test.service.impl.SynchronousEmailService - 发送邮件之前。
13/04 / 2010-22:24:52:625 DEBUG test.service.impl.SynchronousEmailService - 发送邮件后。



具有以下设置的JavaMailSender类:

email.host = smtp.gmail.com

email.username = myaccount@gmail.com
email.password = mypassword
email.port = 465
mail.smtp.auth.required = true

请注意,邮件正在发送,而且我收到的很好,只是这种延迟导致应用程序用户的体验很慢。



如果您知道我可以如何诊断问题本身,这样做也是不错的:) 可能是gmail使用这个延迟来阻止垃圾邮件发送者从外部使用他们的SMTP服务器:如果从实际的webmail客户端调用SMTP,它不会使用此延迟。
为了测试这个,你可以打开一个telnet会话到端口25并执行一个手动SMTP会话
(例如在网上搜索SMTP HELO)

I was wondering if anyone might be able to explain to me why it's taking nearly 30 seconds each time my Java web app sends an email using Gmail's SMTP server? See the following timestamps:

13/04/2010-22:24:27:281 DEBUG test.service.impl.SynchronousEmailService - Before sending mail. 13/04/2010-22:24:52:625 DEBUG test.service.impl.SynchronousEmailService - After sending mail.

I'm using spring's JavaMailSender class with the following settings:

email.host=smtp.gmail.com

email.username=myaccount@gmail.com email.password=mypassword email.port=465 mail.smtp.auth.required=true

Note that the mail is getting sent and I'm receiving it fine, there's just this delay which is resulting in a slow experience for the application user.

If you know how I can diagnose the problem myself that would be good too :)

解决方案

It might be that gmail uses this delay to prevent spammers from using their SMTP server from the "outside": if the SMTP is called from the actual webmail client it would not use this delay. In order to test this, you could open a telnet session to port 25 and do a manual SMTP session (Search the web for SMTP HELO for examples)

这篇关于在Java Web应用程序中使用Gmail作为SMTP服务器速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆