I have the following code that hangs when sending email, the debug output and sendmail log is below.
private Session getSession(){ Properties props = new Properties(); props.put("mail.debug", new Boolean(true)); props.put("mail.smtp.host", this.mailServer); props.put("mail.smtp.ehlo", new Boolean(true)); props.put("mail.smtp.quitwait", new Boolean(false)); Session session = Session.getInstance(props, null); session.setDebug(true); return session; } private void sendAsEmail(String destFileName) throws org.apache.commons.mail.EmailException { log.debug("Sending " + destFileName); // Create the attachment EmailAttachment attachment = new EmailAttachment(); attachment.setPath(destFileName); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription("Excel Report"); attachment.setName("Report." + ("xls".equalsIgnoreCase(this.type) ? "xls":"csv")); // Create the email message MultiPartEmail email = new MultiPartEmail(); email.setMailSession(getSession()); log.debug("Setting host name to " + this.mailServer); email.setHostName(this.mailServer); for(int i = 0 ; i < this.toEmail.length ; i++) { email.addTo(this.toEmail[i]); } email.setFrom(this.fromEmail); if(this.emailSubject != null) { email.setSubject(this.emailSubject); } else { email.setSubject("No Subject"); } if(this.getMessage() != null){ email.setMsg(this.getMessage()); } else { email.setMsg("No Message Provided"); } // add the attachment email.attach(attachment); log.debug("Sending email via " + this.mailServer); // send the email // hangs here. email.send(); log.debug("Mail sent."); } I get the following debug: DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc.,1.4ea] DEBUG SMTP: useEhlo false, useAuth false DEBUG SMTP: trying to connect to host "mail.secmgmt.com", port 25, isSSL false 220 www.secmgmt.com ESMTP Sendmail 8.13.1/8.13.1; Thu, 4 Mar 2010 10:37:24 -0500 DEBUG SMTP: connected to host "mail.secmgmt.com", port: 25 HELO sirrus 250 www.secmgmt.com Hello smcraleigh.secmgmt.com [24.106.188.250], pleased to meet you DEBUG SMTP: use8bit false MAIL FROM:<m...@secmgmt.com> 250 2.1.0 <m...@secmgmt.com>... Sender ok RCPT TO:<m...@secmgmt.com> 250 2.1.5 <m...@secmgmt.com>... Recipient ok DEBUG SMTP: Verified Addresses DEBUG SMTP: "m...@secmgmt.com" <m...@secmgmt.com> DATA 354 Enter mail, end with "." on a line by itself Date: Thu, 4 Mar 2010 10:37:24 -0500 (EST) From: "m...@secmgmt.com" <m...@secmgmt.com> To: "m...@secmgmt.com" <m...@secmgmt.com> Message-ID: <11533424.01267717044165.javamail.r...@sirrus> Subject: Testing the subject MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_0_17237886.1267717044072" ------=_Part_0_17237886.1267717044072 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, testing the message here... ------=_Part_0_17237886.1267717044072 Content-Type: application/octet-stream; name=Report.csv Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=Report.csv Content-Description: Excel Report ------=_Part_0_17237886.1267717044072-- QUIT It hangs at the QUIT, here is what is in Sendmail's log after I ctrl-c: Mar 4 10:37:41 www sendmail[27364]: o24FbOxU027364: collect: premature EOM: unexpected close Mar 4 10:37:41 www sendmail[27364]: o24FbOxU027364: collect: unexpected close on connection from smcraleigh.secmgmt.com, sender=<m...@secmgmt.com>