Closed
Description
Using Version 6.4.3
Couple of issues,
- When sending an email with non-ascii characters, like this,
String attachementName = "⏳.txt";
System.out.println(attachementName);
Email email = EmailBuilder.startingBlank()
.to("foo@gmail.com")
.from("bar@yopmail.com")
.withReplyTo("baz@gmail.com")
.withSubject("hey")
.withHTMLText("<img src='cid:wink1'><b>We should meet up!</b><img src='cid:wink2'>")
.withPlainText("Please view this email in a modern email client!")
.withAttachment(attachementName, IOUtils.toByteArray(attachmentStream), "text/plain")
.buildEmail();
the content generated when seen using withTransportModeLoggingOnly looks like the following,
Content-Type: text/plain; filename="�.txt"; name="�.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="�.txt"
Content-ID: <=?UTF-8?B?4o+z?=>
The filename and name are not encoded correctly. https://tools.ietf.org/html/rfc1342, https://tools.ietf.org/html/rfc1341
- When parsing a email generated by a Outlook client which has the headers like the following,
...
--_004_9e40f9086684426f9ce55a9caffb3ab1Point72com_
Content-Type: text/html;
name="=?Windows-1252?B?Q29uZmlndXJlX1NTT19mb3JfQWRtaW5fQ29uc29sZV9BY2Nlc3Nfll9T?=
=?Windows-1252?Q?ilverfort.pdf.html?="
Content-Description: =?Windows-1252?B?Q29uZmlndXJlX1NTT19mb3JfQWRtaW5fQ29uc29sZV9BY2Nlc3Nfll9T?=
=?Windows-1252?Q?ilverfort.pdf.html?=
Content-Disposition: attachment;
filename="=?Windows-1252?B?Q29uZmlndXJlX1NTT19mb3JfQWRtaW5fQ29uc29sZV9BY2Nlc3Nfll9T?=
=?Windows-1252?Q?ilverfort.pdf.html?="; size=274602;
creation-date="Tue, 29 Sep 2020 14:18:08 GMT";
modification-date="Tue, 29 Sep 2020 16:33:58 GMT"
Content-Transfer-Encoding: base64
...
with code like this,
InputStream emailStream = new FileInputStream("somefile.eml");
MimeMessage mm = new MimeMessage(null, emailStream);
Email email = EmailBuilder.copying(mm).buildEmail();
It fails with,
org.simplejavamail.mailer.MailValidationException: Suspected of injection attack, field: email.header.Content-Description with suspicious value: =?Windows-1252?B?Q29uZmlndXJlX1NTT19mb3JfQWRtaW5fQ29uc29sZV9BY2Nlc3Nfll9T?=
=?Windows-1252?Q?ilverfort.pdf.html?=
at org.simplejavamail.mailer.MailerHelper.scanForInjectionAttack(MailerHelper.java:139)
at org.simplejavamail.mailer.MailerHelper.validate(MailerHelper.java:97)
at org.simplejavamail.mailer.internal.MailerImpl.validate(MailerImpl.java:361)
at org.simplejavamail.mailer.internal.MailerImpl.sendMail(MailerImpl.java:339)
at org.simplejavamail.mailer.internal.MailerImpl.sendMail(MailerImpl.java:330)