Transport.send()需要15分钟才能完成

时间:2015-10-08 09:28:36

标签: java android sockets javamail

我知道这个问题早些时候曾在这里提出过。我已经看到了提供的所有解决方案和输入。但我无法解决这个问题。 早些时候,相同的代码工作正常,现在每个发送调用大约需要15-20分钟才能执行。

我想我正在传递正确的论点。有人能告诉我为什么需要这么多时间吗?

这是LOG文件:

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

代码:

C:\Users\Digital Jalebi - uno\Desktop\naval.txt
Fetched from filenavaljosh@gmail.com;nn.jpg
Email:navaljosh@gmail.comimage:C:\Users\Digital Jalebi - uno\Desktop\naval\nn.jpg
Filling details
send to mail auth file
navaljosh@gmail.com
lenth receipient2
Filling final msg
1
2
3
4
< here it waits for 15 minutes - on transport.send() and then gets executed>
5
From: Navaljoshi <navaljosh@gmail.com>
Reply-to: Navaljoshi <navaljosh@gmail.com>
To: jabongnbajam@gmail.com
Subject: Fwd: EXTRA 32% Off on 2Lac+ Styles
Sent: Thu Oct 08 11:18:14 IST 2015
javax.mail.internet.MimeMultipart@72e1bc00
message forwarded ....
Sucessfully Sent mail to All Users
Fetched from filenull
sleeping1
woke1
Fetched from filenull
sleeping1

2 个答案:

答案 0 :(得分:0)

您可以通过修复所有这些common mistakes来清理您的程序,然后按照此example for using Gmail进行清理。

如果这不能解决您的问题(而且我认为不会),请启用JavaMail Session debugging;通过观察调试输出暂停的位置,您可以确定它在减速时正在做什么。最有可能的问题是名称服务问题(查找Gmail的主机名),或者插入连接尝试的防火墙或防病毒程序。

答案 1 :(得分:-1)

您正在设置mail.smtp.host两次。

props.put(“mail.smtp.host”,“smtp.gmail.com”);  props.put(“mail.smtp.host”,HOST_NAME);

仅使用一台主机进行测试并查看。

您还可以添加属性以查看邮件服务器连接是否存在问题。

properties.put(“mail.smtp.connectiontimeout”,“15000”);

P