Skip to content
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

fix MimeMessage::formatAddress not protecting recipient names #180

Closed
wants to merge 1 commit into from

Conversation

Plaristote
Copy link
Contributor

Greetings !

Right now, trying to send an email, to someone whose name contains a comma, results in a ClientError. According to the following topic :

https://stackoverflow.com/questions/15555563/how-to-format-an-email-from-header-that-contains-a-comma

... it seems that to prevent this issue, names in mail headers should be escaped using double quotes. This pull request achieves this result using stringstream and some iomanip magic. It does imply a back-and-forth conversion between QByteArray and std::string... but I don't believe Qt provides their own implementation for something like std::quoted, so this seemed like the simplest way to reach the goal.

@attila-tokes
Copy link
Collaborator

@Plaristote, have you tried to set the header encoding to QuotedPrintable or Base64? If the special character are only in the recipient's name (and not in the email address), it should resolve this problem.

attila-tokes added a commit that referenced this pull request Jan 24, 2025
@bluetiger9
Copy link
Owner

Hi @Plaristote! 🙂

Checked today, and using , in names works with MimePart::Encoding::Base64.

With MimePart::Encoding::QuotedPrintable commas were not escaped by default. I made a fix in 014970d, and now QuotedPrintable works too.

Using the default _8Bit encoding is usually not a good idea arbitrary names and headers. For now I will not add escaping as QuotedPrintable and Base64 are supposedly a much better solution for handling arbitrary Unicode content.

Also, I changes all the example / demo files to use MimePart::Encoding::QuotedPrintable by default.

Thanks!

@bluetiger9 bluetiger9 closed this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants