See Thread at: http://www.techienuggets.com/Detail?tx=57811 Posted on behalf of a User
I use the same code in 2 ways : 1/ In a simple java project with Eclipse 2/ In a Tomcat application When I send a mail in a simple java project, it works. The mail is sent with subject and body. When I use the same code at the start of a tomcat server, it doesn't work. The mail is sent but there is no body. I send the trace for the both case. I don't understand why This is the code : Properties props = new Properties(); props.put("mail.smtp.host", "MESSAGERIE"); props.put("mail.smtp.auth", "false"); Session session = Session.getDefaultInstance(props); session.setDebug(true); MimeMessage message = new MimeMessage(session); message.setContent("Hello this is the body of the mail","text/plain"); message.setFrom(new InternetAddress("unknown")); InternetAddress dests[] = new InternetAddress[] { new InternetAddress("[EMAIL PROTECTED]") }; message.setRecipients(Message.RecipientType.TO, dests); message.setSubject("Sujet"); Transport.send(message); Trace when it works in a simple java project : DEBUG: setDebug: JavaMail version 1.4.1 [EMAIL PROTECTED] DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "MESSAGERIE.castel.fr", port 25, isSSL false 220 Messagerie.castel.fr Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Fri, 24 Oct 2008 11:20:49 +0200 DEBUG SMTP: connected to host "MESSAGERIE.castel.fr", port: 25 EHLO LABOLLC 250-Messagerie.castel.fr Hello [192.168.49.19] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-EXPS GSSAPI NTLM LOGIN 250-X-EXPS=LOGIN 250-AUTH GSSAPI NTLM LOGIN 250-AUTH=LOGIN 250-X-LINK2STATE 250-XEXCH50 250 OK DEBUG SMTP: Found extension "TURN", arg "" DEBUG SMTP: Found extension "SIZE", arg "" DEBUG SMTP: Found extension "ETRN", arg "" DEBUG SMTP: Found extension "PIPELINING", arg "" DEBUG SMTP: Found extension "DSN", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: Found extension "8bitmime", arg "" DEBUG SMTP: Found extension "BINARYMIME", arg "" DEBUG SMTP: Found extension "CHUNKING", arg "" DEBUG SMTP: Found extension "VRFY", arg "" DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM LOGIN" DEBUG SMTP: Found extension "X-EXPS=LOGIN", arg "" DEBUG SMTP: Found extension "AUTH", arg "GSSAPI NTLM LOGIN" DEBUG SMTP: Found extension "AUTH=LOGIN", arg "" DEBUG SMTP: Found extension "X-LINK2STATE", arg "" DEBUG SMTP: Found extension "XEXCH50", arg "" DEBUG SMTP: Found extension "OK", arg "" DEBUG SMTP: use8bit false MAIL FROM:<unknown> 250 2.1.0 [EMAIL PROTECTED] OK RCPT TO:<[EMAIL PROTECTED]> 250 2.1.5 [EMAIL PROTECTED] DEBUG SMTP: Verified Addresses DEBUG SMTP: [EMAIL PROTECTED] DATA 354 Start mail input; end with <CRLF>.<CRLF> From: unknown To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> Subject: Sujet MIME-Version: 1.0 Content-Type: text/plain;charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Hello this is the body of the mail =============> this is the content !!! . 250 2.6.0 <[EMAIL PROTECTED]> Queued mail for delivery QUIT 221 2.0.0 Messagerie.castel.fr Service closing transmission channel Trace when it doesn't work :When tomcat is starting !!! DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "MESSAGERIE.castel.fr", port 25, isSSL false 220 Messagerie.castel.fr Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Fri, 24 Oct 2008 11:21:56 +0200 DEBUG SMTP: connected to host "MESSAGERIE.castel.fr", port: 25 EHLO LABOLLC 250-Messagerie.castel.fr Hello [192.168.49.19] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-EXPS GSSAPI NTLM LOGIN 250-X-EXPS=LOGIN 250-AUTH GSSAPI NTLM LOGIN 250-AUTH=LOGIN 250-X-LINK2STATE 250-XEXCH50 250 OK DEBUG SMTP: Found extension "TURN", arg "" DEBUG SMTP: Found extension "SIZE", arg "" DEBUG SMTP: Found extension "ETRN", arg "" DEBUG SMTP: Found extension "PIPELINING", arg "" DEBUG SMTP: Found extension "DSN", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: Found extension "8bitmime", arg "" DEBUG SMTP: Found extension "BINARYMIME", arg "" DEBUG SMTP: Found extension "CHUNKING", arg "" DEBUG SMTP: Found extension "VRFY", arg "" DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM LOGIN" DEBUG SMTP: Found extension "X-EXPS=LOGIN", arg "" DEBUG SMTP: Found extension "AUTH", arg "GSSAPI NTLM LOGIN" DEBUG SMTP: Found extension "AUTH=LOGIN", arg "" DEBUG SMTP: Found extension "X-LINK2STATE", arg "" DEBUG SMTP: Found extension "XEXCH50", arg "" DEBUG SMTP: Found extension "OK", arg "" DEBUG SMTP: use8bit false MAIL FROM:<unknown> 250 2.1.0 [EMAIL PROTECTED] OK RCPT TO:<[EMAIL PROTECTED]> 250 2.1.5 [EMAIL PROTECTED] DEBUG SMTP: Verified Addresses DEBUG SMTP: [EMAIL PROTECTED] DATA 354 Start mail input; end with <CRLF>.<CRLF> From: unknown To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> Subject: Sujet MIME-Version: 1.0 Content-Type: text/plain;charset="iso-2022-jp" Content-Transfer-Encoding: 7bit ======> there is no content . 250 2.6.0 <[EMAIL PROTECTED]> Queued mail for delivery QUIT 221 2.0.0 Messagerie.castel.fr Service closing transmission channel --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]