Why does gmail close my connection when I send email through Javamail
I have a process (Message Driven Bean) that sends emails every time it gets a message. Emails per message are less than 10. I open 1 connection to my gmail account and send all开发者_StackOverflow社区 emails over that one connection. Every now and then, I get an Exception on Transport.send()
javax.mail.MessagingException: Can't send command to SMTP host; nested exception is:
java.net.SocketException: Connection closed by remote host at
com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1878) at
com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1865) at
com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:973) at
javax.mail.Transport.send0(Transport.java:193) at
javax.mail.Transport.send(Transport.java:120) at
....
Is gmail closing the connection because it thinks that it is spam? I know there is a limitation on number of cocurrent connections to gmail (10) but this seems different. Would using a connection pool help?
Either Gmail time out on your TCP/IP connection and decides to close it, or a firewall in between detects the connection to be idle and closes it.
精彩评论