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 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?