Javamail发送带有附件的邮件在Windows上工作,但在Linux上不工作

Javamail发送带有附件的邮件在Windows上工作,但在Linux上不工作,java,jakarta-ee,tomcat6,jakarta-mail,Java,Jakarta Ee,Tomcat6,Jakarta Mail,我在Tomcat6.0上使用Javamail通过linux发送带有附件的电子邮件时遇到问题 在我的机器(Windows764)上使用Tomcat服务器发送邮件时,它工作正常。我已经用本地smtp服务器和gmail帐户作为中继进行了测试。但是,当邮件由我的远程Tomcat服务器(运行linux)发送时,收到的邮件很混乱,没有主题,附件显示为文本(原始是pdf文件),一些邮件标题与邮件混合在一起。我尝试过使用在Windows上测试时使用的方法:尝试使用本地smtp服务器,然后使用gmail作为中继。

我在Tomcat6.0上使用Javamail通过linux发送带有附件的电子邮件时遇到问题

在我的机器(Windows764)上使用Tomcat服务器发送邮件时,它工作正常。我已经用本地smtp服务器和gmail帐户作为中继进行了测试。但是,当邮件由我的远程Tomcat服务器(运行linux)发送时,收到的邮件很混乱,没有主题,附件显示为文本(原始是pdf文件),一些邮件标题与邮件混合在一起。我尝试过使用在Windows上测试时使用的方法:尝试使用本地smtp服务器,然后使用gmail作为中继。这两种情况都不起作用

我还尝试更改本地JavaMail库,并使用远程服务器上的相同库(从服务器复制到我的机器),但运行本地的结果总是相同的。电子邮件以预期的方式接收

当我发送电子邮件时,它会向我发送另一份副本,这样我就可以跟踪正在发生的事情。下面的日志中显示了在使用嵌入在我的j2ee.jar中的Javamail运行本地测试时,两个邮件(原始邮件和副本邮件)的Javamail输出(有关更多详细信息,请参见下文):

DEBUG:setDebug:JavaMail版本1.3.1
调试:getProvider()返回javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,sun Microsystems,Inc]
调试SMTP:useEhlo true,useAuth true
调试SMTP:useEhlo true,useAuth true
调试SMTP:尝试连接到主机“SMTP.gmail.com”,端口587
220 mx.google.com ESMTP jz16sm6498879vdb.9
调试SMTP:已连接到主机“SMTP.gmail.com”,端口:587
埃洛·菲利佩惠普公司
250-mx.google.com为您服务,[177.17.162.156]
250号35882577
250-8比特
250-AUTH登录普通XOATH
250-增强状态码
250标准
调试SMTP:找到扩展名“大小”,参数“35882577”
调试SMTP:找到扩展名“8BITMIME”,参数“”
调试SMTP:找到扩展名“AUTH”,arg“LOGIN PLAIN XOAUTH”
调试SMTP:找到扩展名“ENHANCEDSTATUSCODES”,arg“”
调试SMTP:找到扩展名“STARTTLS”,arg“”
调试SMTP:尝试进行身份验证
身份验证登录
334 xxxxxxxxx
334 xxxxxxxxx
235 2.7.0接受
调试SMTP:use8bit false
邮寄地址:
250 2.1.0正常jz16sm6498879vdb.9
RCPT至:
250 2.1.5正常jz16sm6498879vdb.9
调试SMTP:已验证的地址
调试SMTP:xxxxx@xxxxx.xxxx.xxxx
资料
354请继续jz16sm6498879vdb。9
消息ID:
发件人:xxxxx@xxxxx.xxxx.xxxx
致:xxxxx@xxxxx.xxxx.xxxx
主题:Boleto Amaua-2012年5月6日
Mime版本:1.0
内容类型:多部分/混合;
boundary=“---=\u Part\u 0\u 1451495453.1335464128994”
------=_零件_0_1451495453.1335464128994
内容类型:文本/纯文本;字符集=ISO-8859-1
内容传输编码:引用可打印
内容配置:内联
------=_零件_0_1451495453.1335464128994
内容类型:应用程序/八位字节流;
name=boleto-158-255-1335464128903.pdf
内容传输编码:base64
内容处置:附件;filename=boleto-158-255-1335464128903.pdf
内容描述:随附文件:boleto-158-255-1335464128903.pdf
------=_零件_0_1451495453.1335464128994--
.
250 2.0.0正常1335464133 jz16sm6498879vdb.9
退出
调试:setDebug:JavaMail版本1.3.1
调试:getProvider()返回javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,sun Microsystems,Inc]
调试SMTP:useEhlo true,useAuth true
调试SMTP:useEhlo true,useAuth true
调试SMTP:尝试连接到主机“SMTP.gmail.com”,端口587
220 mx.google.com ESMTP jz16sm6499184vdb.9
调试SMTP:已连接到主机“SMTP.gmail.com”,端口:587
埃洛·菲利佩惠普公司
250-mx.google.com为您服务,[177.17.162.156]
250号35882577
250-8比特
250-AUTH登录普通XOATH
250-增强状态码
250标准
调试SMTP:找到扩展名“大小”,参数“35882577”
调试SMTP:找到扩展名“8BITMIME”,参数“”
调试SMTP:找到扩展名“AUTH”,arg“LOGIN PLAIN XOAUTH”
调试SMTP:找到扩展名“ENHANCEDSTATUSCODES”,arg“”
调试SMTP:找到扩展名“STARTTLS”,arg“”
调试SMTP:尝试进行身份验证
身份验证登录
334 XXXXXXXXX
334 XXXXXXXXX
235 2.7.0接受
调试SMTP:use8bit false
邮寄地址:
250 2.1.0正常jz16sm6499184vdb.9
RCPT至:
250 2.1.5正常jz16sm6499184vdb.9
调试SMTP:xxxxx@xxxxx.xxxx.xxxx
调试SMTP:xxxxx@xxxxx.xxxx.xxxx
资料
354请继续jz16sm6499184vdb。9
消息ID:
发件人:xxxxx@xxxxx.xxxx.xxxx
致:xxxxx@xxxxx.xxxx.xxxx
主题:=?ISO-8859-1?Q?C=2012年5月6日=
Mime版本:1.0
内容类型:多部分/混合;
boundary=“---=\u Part\u 1\u 1973765399.133546435”
------=第1部分\u 1973765399.133546435
内容类型:文本/纯文本;字符集=ISO-8859-1
内容传输编码:引用可打印
内容配置:内联
###################################################################
邮件内容
###################################################################
------=第1部分\u 1973765399.133546435
内容类型:应用程序/八位字节流;
name=boleto-158-255-1335464128903.pdf
内容传输编码:base64
内容处置:附件;filename=boleto-158-255-1335464128903.pdf
内容描述:随附文件:boleto-158-255-1335464128903.pdf
##################################################################
附件内容
##################################################################
------=第1部分\u 1973765399.133546435--
.
250 2.0.0正常1335464137 jz16sm6499184vdb.9
退出
下面显示了我的服务器生成的日志:

Loading javamail.default.providers from jar:file:/opt/tomcat60/lib/mail.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=imap, className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=imaps, className=com.sun.mail.imap.IMAPSSLStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtp, className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtps, className=com.sun.mail.smtp.SMTPSSLTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3, className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3s, className=com.sun.mail.pop3.POP3SSLStore, vendor=Sun Microsystems, Inc, version=null

Loading javamail.default.providers from jar:file:/home/xxxxxxx/public_html/WEB-INF/lib/mail.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=imap, className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=imaps, className=com.sun.mail.imap.IMAPSSLStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtp, className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtps, className=com.sun.mail.smtp.SMTPSSLTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3, className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3s, className=com.sun.mail.pop3.POP3SSLStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: getProvider() returning provider protocol=smtp; type=javax.mail.Provider$Type@67aece; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc

DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false
220 mx.google.com ESMTP dc7sm2927045vdc.6
DEBUG SMTP: connected to host "smtp.gmail.com", port: 587

EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN succeeded
DEBUG SMTP: use8bit false
MAIL FROM:<xxxxx@xxxxx.xxxx.xxxx>
250 2.1.0 OK dc7sm2927045vdc.6
RCPT TO:<xxxxx@xxxxx.xxxx.xxxx>
250 2.1.5 OK dc7sm2927045vdc.6
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   xxxxx@xxxxx.xxxx.xxxx
DATA
354  Go ahead dc7sm2927045vdc.6

------=_Part_0_16475596.1335412817148
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

###################################################################
Mail Content
###################################################################

------=_Part_0_16475596.1335412817148
Content-Type: application/octet-stream; name=boleto-1436-1707-1335412817075.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=boleto-1436-1707-1335412817075.pdf
Content-Description: Attached file: boleto-1436-1707-1335412817075.pdf

##################################################################
Attachment content
##################################################################

------=_Part_0_16475596.1335412817148--
.
250 2.0.0 OK 1335412824 dc7sm2927045vdc.6
QUIT
221 2.0.0 closing connection dc7sm2927045vdc.6









DEBUG: getProvider() returning provider protocol=smtp; type=javax.mail.Provider$Type@67aece; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false
220 mx.google.com ESMTP c17sm2919516vdj.12
DEBUG SMTP: connected to host "smtp.gmail.com", port: 587

EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN succeeded
DEBUG SMTP: use8bit false
MAIL FROM:<xxxxxxx@xxxxx.xxxx.xxxx>
250 2.1.0 OK c17sm2919516vdj.12
RCPT TO:<xxxxx@xxxxx.xxxx.xxxx>
250 2.1.5 OK c17sm2919516vdj.12
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   xxxxx@xxxxx.xxxx.xxxx
DATA
354  Go ahead c17sm2919516vdj.12

------=_Part_1_22662950.1335412824767
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

###################################################################
Mail Content
###################################################################

------=_Part_1_22662950.1335412824767
Content-Type: application/octet-stream; name=boleto-1436-1707-1335412817075.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=boleto-1436-1707-1335412817075.pdf
Content-Description: Attached file: boleto-1436-1707-1335412817075.pdf

##################################################################
Attachment content
##################################################################

------=_Part_1_22662950.1335412824767--
.
250 2.0.0 OK 1335412828 c17sm2919516vdj.12
QUIT
221 2.0.0 closing connection c17sm2919516vdj.12
从jar:file:/opt/tomcat60/lib/mail.jar加载javamail.default.providers/META-INF/javamail.default.providers
调试:加载新的提供程序协议=imap,className=com.sun.mail.imap.IMAPStore,vendor=sun Microsystems,Inc,version=null
调试:加载新的提供程序协议=imaps,类名称=com.sun.mail.imap.IMAPSSLStore,供应商=sun Microsystems,Inc,版本=null
调试:加载新的提供程序协议=smtp,
Loading javamail.default.providers from jar:file:/opt/tomcat60/lib/mail.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=imap, className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=imaps, className=com.sun.mail.imap.IMAPSSLStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtp, className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtps, className=com.sun.mail.smtp.SMTPSSLTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3, className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3s, className=com.sun.mail.pop3.POP3SSLStore, vendor=Sun Microsystems, Inc, version=null

Loading javamail.default.providers from jar:file:/home/xxxxxxx/public_html/WEB-INF/lib/mail.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=imap, className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=imaps, className=com.sun.mail.imap.IMAPSSLStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtp, className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=smtps, className=com.sun.mail.smtp.SMTPSSLTransport, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3, className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc, version=null
DEBUG: loading new provider protocol=pop3s, className=com.sun.mail.pop3.POP3SSLStore, vendor=Sun Microsystems, Inc, version=null
DEBUG: getProvider() returning provider protocol=smtp; type=javax.mail.Provider$Type@67aece; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc

DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false
220 mx.google.com ESMTP dc7sm2927045vdc.6
DEBUG SMTP: connected to host "smtp.gmail.com", port: 587

EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN succeeded
DEBUG SMTP: use8bit false
MAIL FROM:<xxxxx@xxxxx.xxxx.xxxx>
250 2.1.0 OK dc7sm2927045vdc.6
RCPT TO:<xxxxx@xxxxx.xxxx.xxxx>
250 2.1.5 OK dc7sm2927045vdc.6
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   xxxxx@xxxxx.xxxx.xxxx
DATA
354  Go ahead dc7sm2927045vdc.6

------=_Part_0_16475596.1335412817148
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

###################################################################
Mail Content
###################################################################

------=_Part_0_16475596.1335412817148
Content-Type: application/octet-stream; name=boleto-1436-1707-1335412817075.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=boleto-1436-1707-1335412817075.pdf
Content-Description: Attached file: boleto-1436-1707-1335412817075.pdf

##################################################################
Attachment content
##################################################################

------=_Part_0_16475596.1335412817148--
.
250 2.0.0 OK 1335412824 dc7sm2927045vdc.6
QUIT
221 2.0.0 closing connection dc7sm2927045vdc.6









DEBUG: getProvider() returning provider protocol=smtp; type=javax.mail.Provider$Type@67aece; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false
220 mx.google.com ESMTP c17sm2919516vdj.12
DEBUG SMTP: connected to host "smtp.gmail.com", port: 587

EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
EHLO l50dnn0358.locaweb.com.br
250-mx.google.com at your service, [187.45.198.10]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250-ENHANCEDSTATUSCODES
250 PIPELINING
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN succeeded
DEBUG SMTP: use8bit false
MAIL FROM:<xxxxxxx@xxxxx.xxxx.xxxx>
250 2.1.0 OK c17sm2919516vdj.12
RCPT TO:<xxxxx@xxxxx.xxxx.xxxx>
250 2.1.5 OK c17sm2919516vdj.12
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   xxxxx@xxxxx.xxxx.xxxx
DATA
354  Go ahead c17sm2919516vdj.12

------=_Part_1_22662950.1335412824767
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

###################################################################
Mail Content
###################################################################

------=_Part_1_22662950.1335412824767
Content-Type: application/octet-stream; name=boleto-1436-1707-1335412817075.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=boleto-1436-1707-1335412817075.pdf
Content-Description: Attached file: boleto-1436-1707-1335412817075.pdf

##################################################################
Attachment content
##################################################################

------=_Part_1_22662950.1335412824767--
.
250 2.0.0 OK 1335412828 c17sm2919516vdj.12
QUIT
221 2.0.0 closing connection c17sm2919516vdj.12
Properties props = new Properties();
props.put("mail.smtp.debug", "true");
props.put("mail.smtp.auth", "true");
props.put("mail.mime.charset", "ISO-8859-1"); 
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.starttls.required", "true");
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", Integer.toString(port));
this.session = Session.getInstance(props,
    new javax.mail.Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
         return new PasswordAuthentication(usr, pass);
      }
});

MimeMultipart mp = new MimeMultipart("mixed");
MimeBodyPart txtPart = new MimeBodyPart();

if(this.message == null){
    if(this.session != null){
       this.message = new MimeMessage(this.session);
    } else {
       throw new Exception("");
    }
}

this.session.setDebug(true);
this.message.setFrom(new InternetAddress(this.from));
this.message.setRecipient(Message.RecipientType.TO, new InternetAddress(this.to));
this.message.setSubject(this.subject);

txtPart.setDisposition(Part.INLINE);
txtPart.setText(text);
mp.addBodyPart(txtPart);

for (int i = 0; i < this.attach.size(); i++) {
    MimeBodyPart filePart = new MimeBodyPart();
    File file = (File) this.attach.elementAt(i);
    FileDataSource fds = new FileDataSource(file);
    DataHandler dh = new DataHandler(fds);
    filePart.setFileName(file.getName());
    filePart.setDisposition(Part.ATTACHMENT);
    filePart.setDescription("Attached file: " + file.getName());
    filePart.setDataHandler(dh);
    mp.addBodyPart(filePart);
}

this.message.setContent(mp);

Transport.send(this.message);