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 for emojis in subject and mail body #300

Open
kilbiller opened this issue Aug 28, 2024 · 2 comments
Open

Fix for emojis in subject and mail body #300

kilbiller opened this issue Aug 28, 2024 · 2 comments

Comments

@kilbiller
Copy link

kilbiller commented Aug 28, 2024

Hello,

As #158 points out, there is an issue with this lib when trying to use an utf8 encoded emoji (such as this one 😀) in the Subject Html-part or Text-part of a campaign/transactional mail.

I sadly don't have the time to create a PR but here is the reason why it happens and a potential fix in case someone else wants to fix it or runs into it.

Guzzle is used under the hood to make the http requests and this lib uses the json request option when sending json data in the body (which happens for most endpoints). When this option is used, Guzzle automatically sets the content-type header and wraps the body like this json_encode($body) before sending the request. This breaks the emojis.

A potential fix for this lib would be to not use the json option and instead manually add the correct content-type header and encode the body like so json_encode($body, JSON_UNESCAPED_UNICODE) as it doesn't break emojis.

Hope this might be of help.

@oleksandr-mykhailenko
Copy link
Collaborator

Hello,

As #158 points out, there is an issue with this lib when trying to use an utf8 encoded emoji (such as this one 😀) in the Subject Html-part or Text-part of a campaign/transactional mail.

I sadly don't have the time to create a PR but here is the reason why it happens and a potential fix in case someone else wants to fix it or runs into it.

Guzzle is used under the hood to make the http requests and this lib uses the json request option when sending json data in the body (which happens for most endpoints). When this option is used, Guzzle automatically sets the content-type header and wraps the body like this json_encode($body) before sending the request. This breaks the emojis.

A potential fix for this lib would be to not use the json option and instead manually add the correct content-type header and encode the body like so json_encode($body, JSON_UNESCAPED_UNICODE) as it doesn't break emojis.

Hope this might be of help.

Hello @kilbiller
Thank you for your notice. We will try this solution and test

@HugoDiag
Copy link

Hello,

Came with a PR for this.

Feel free to check it and tell me if anything is wrong

Have a good day

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

No branches or pull requests

3 participants