Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1DC399BAF for ; Wed, 18 Apr 2012 13:45:20 +0000 (UTC) Received: (qmail 30840 invoked by uid 500); 18 Apr 2012 13:45:16 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 30703 invoked by uid 500); 18 Apr 2012 13:45:16 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 30694 invoked by uid 99); 18 Apr 2012 13:45:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 13:45:16 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jdesodt@gmail.com designates 74.125.83.45 as permitted sender) Received: from [74.125.83.45] (HELO mail-ee0-f45.google.com) (74.125.83.45) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 13:45:09 +0000 Received: by eeit10 with SMTP id t10so3141463eei.18 for ; Wed, 18 Apr 2012 06:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=T59bESoGK8++K2vyzCRpxC5bYN5k1nnxk6cIEbgJOmQ=; b=hhmhocn5OkDcaB6GOjp6hStaea8yaPqDveEPM66M9rdp7i20Krzl5YRT7VU0um20pL d89klRGkeM+w0WNnGhPAsl5zmAhTdWHzZOPp8YhxJF+VoQ8QD/+d+ZJOYTYmfLxjKQN6 wZJM0VrABaRlDA/e8cbxiSkzAeOxkgyOCOePWFM+hSzB1kiHpQZG5QvUpJ9QNZUYy4NB CGgYCN+vsPRdw5KwgYZx5F2Cp39irLUtNiCr/mko0t3xJqtYaeMVGkORzK4L7GH1/FsK CxBvKX/m+yB/6sOKTDboJ842DBCAp/OWDewV2njUFO4WjgVnAZoovTfsqRxh50HG7Eg7 4KAQ== MIME-Version: 1.0 Received: by 10.213.105.147 with SMTP id t19mr196297ebo.203.1334756688387; Wed, 18 Apr 2012 06:44:48 -0700 (PDT) Received: by 10.213.4.194 with HTTP; Wed, 18 Apr 2012 06:44:48 -0700 (PDT) In-Reply-To: <4F8E1D13.1020406@christopherschultz.net> References: <4F8E1D13.1020406@christopherschultz.net> Date: Wed, 18 Apr 2012 15:44:48 +0200 Message-ID: Subject: Re: In webapp, sending multipart email with Javamail : noname attachment instead of message From: Jacques Desodt To: Tomcat Users List Content-Type: multipart/alternative; boundary=0015174c401845dce404bdf4420d --0015174c401845dce404bdf4420d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Chris, Thanks a lot for your quick reply ! My apologies for the image posted, I didn't know it could be stripped by the mailing list. OK, I will test your solution tonight. I agree with you, Javamail API is really complicated, I always used Apache Commons Email. I will have a look at your great project. Jacques 2012/4/18 Christopher Schultz > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Jacques, > > On 4/17/12 12:45 PM, Jacques Desodt wrote: > > I try to send a Multipart email in a simple java method, using > > Javamail. When i use the method in a local java app, everything is > > fine. When i use the same method in a webapp hosted by Tomcat, i > > got no message, but a file "noname" in attachment. > > Your code looks reasonable. I wonder if you are missing some system > property when running under Tomcat, since you use the system > properties as a basis for your JavaMail session setup. > > Try using an empty Properties object instead of taking > System.getProperties() and mutating that. You might find that there is > some property available in your standalone environment that you are > missing in the Tomcat one. > > > And here are the results (i use gmail) : > > > > Images int=E9gr=E9es 1 > > (I'm not sure what that means... if you attached something to your > email, it was stripped by the mailing list). > > > The first (and wrong) email came from the Tomcat server. It has no > > message, and an attachment with "noname" name. The other email is > > good and came from my java app. > > What are the differences when you look at the actual source code of > the message? You can learn a lot from looking at the raw MIME message. > > BTW, if you intend to move from a simple multipart text message as you > have above to something more complicated (such as text + HTML + > attachments) be aware that the JavaMail API is a complete main in the > neck to use. I would highly recommend using a wrapper API such as > commons-email or my own emailer wrapper you can find at > http://christopherschultz.net/projects/java/ > > I happen to like mine better ;) > > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG/MacGPG2 v2.0.17 (Darwin) > Comment: GPGTools - http://gpgtools.org > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAk+OHRMACgkQ9CaO5/Lv0PDk6wCgtsLID0HPf6nNH2bFc/ThfrTl > J58AnjuTcjIFhj1QOgESVmgMFK5jWOBC > =3DQXQU > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --0015174c401845dce404bdf4420d--