-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment (file)names with special characters should not be encoded #271
Comments
This is valid encoding according to the RFC, but the client seems to parse it incorrectly. In what email client does the recipient view this result? |
The attachment has an incorrect name directly, for example gmail.com. Sample code reproducing the error. String host = "smtp.gmail.com";
int port = 587;
String name = "";
String password = "";
TransportStrategy transportStrategy = TransportStrategy.SMTP_TLS;
String path = "E://Testowy_załącznik_ąśćńółęĄŻŹĆŃÓŁĘ.txt";
File file = new File(path);
DataSource ds = new FileDataSource(file);
Email email = EmailBuilder
.startingBlank()
.from("")
.to("")
.withSubject("test")
.withAttachment("Testowy_załącznik_ąśćńółęĄŻŹĆŃÓŁĘ.txt", ds)
.buildEmail();
Mailer mailer = MailerBuilder
.withSMTPServer(host, port, name, password)
.withTransportStrategy(transportStrategy)
.buildMailer();
mailer.sendMail(email); |
Also see: https://javaee.github.io/javamail/FAQ#encodefilename I'm going to turn off encoding of filenames, while making sure file names are tested for injection attacks. |
…/image file names are tested for injection attacks. Update the master demo
Fix released in 6.3.2 |
@bbottema |
When adding an attachment:
Testowy_załącznik_ąśćńółęĄŻŹĆŃÓŁĘ.txt
to an email and positive delivery, the recipient receives the attachment with the changed name:
=UTF-8_Q_Testowy=5Fza=C5=82=C4=85cznik=5F= =UTF-8_Q=C4=85=C5=9B=C4=87=C5=84=C3=B3=C5=82=C4=99=C4=84=C5=BB_= =UTF-8_Q=C5=B9=C4=86=C5=83=C3=93=C5=81=C4=98.txt_=.txt
After a small investigation, I find that the reason for this is using
MimeUtility.encodeText (name, UTF_8.name (), "B")
for the name of the attachment. I suggest using one of two solutions:
The text was updated successfully, but these errors were encountered: