【发布时间】:2012-04-24 11:46:23
【问题描述】:
我正在尝试通过apache.commons.mail 发送一个base64 编码的文件,但我无法将Content-Transfer-Encoding: base64 标头放到应该去的地方。
// Create the email
MultiPartEmail email = new MultiPartEmail();
email.setSmtpPort(587);
email.setDebug(false);
email.setHostName("smtp.gmail.com");
email.setAuthentication("from@gmail.com", "password");
email.setTLS(true);
email.addTo("to@example.com");
email.setFrom("from@example.com");
email.setSubject("subject");
email.attach(new ByteArrayDataSource(
Base64.encodeBase64(attachFull.getBytes()), "text/plain"),
"samplefile.txt",
"sample file desc",
EmailAttachment.ATTACHMENT
);
这就是到达接收者的东西。
------=_Part_0_614021571.1334210788719
Content-Type: text/plain; charset=Cp1252; name=texto.txt
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=samplefile.txt
Content-Description: sample file desc
如何指定文件是 Base64 编码的?
【问题讨论】:
标签: java base64 apache-commons-email