- Issue created by @skylord
- Status changed to Needs review
over 1 year ago 6:51am 23 March 2023 - Status changed to Fixed
over 1 year ago 9:07pm 23 March 2023 - 🇦🇺Australia imclean Tasmania
Actually this isn't the way to do it. The charset can be set in the content-type header.
What are the steps to replicate this? Versions, sending module (not mail module) etc.
🐛 Email attachments no longer working Closed: duplicate
- Status changed to Closed: works as designed
over 1 year ago 10:10pm 2 May 2023 With this fix reversed we have problem that our email has the wrong encoding (using german umlauts).
Where would this charset be set?- Status changed to Postponed: needs info
over 1 year ago 10:06pm 23 May 2023 - 🇦🇺Australia imclean Tasmania
@spruce, can you provide the exact steps to replicate the problem? How are you sending email, where is the wrong charset being shown? Headers (which ones?), body?
- Status changed to Needs review
over 1 year ago 1:45am 26 May 2023 - 🇦🇺Australia imclean Tasmania
It looks like the charset is being set after the other headers have been processed. This patch moves it before the other headers.
The default is UTF-8, but you can set it in the Content-Type header.
Does this resolve the issue @skylord and @spruce?
- Status changed to Closed: works as designed
over 1 year ago 10:22pm 12 June 2023 - 🇦🇺Australia imclean Tasmania
I can't replicate this so I can't tell if the patch in #11 resolves it. If you can provide a set of instructions to demonstrate the the problem then reopen the issue and post it here.
Hi,
It seems the symptom occurs when adding "$message['headers']['Content-Type'] = "text/html";" in hook_mail().Steps to reproduce
1)Upgrade module from 2.1.0 to 2.2.3.
2)Install → module 4.0.2.
3)Modify /examples/modules/email_example/email_example.module.
L.53
case 'contact_message':
/* add this */ $message['headers']['Content-Type'] = "text/html";
$from = \Drupal::config('system.site')->get('mail');
4)Login to your website as administrator, and go to /examples/email-example (or click Examples > Email Example of menu bar).
Enter your email address in the E-mail address field, enter "あいう" of Japanese in the Message field, and Click Submit button.
5)Received email shows wrong characters. (See some_characters_wrong.png.)- 🇦🇺Australia imclean Tasmania
@kubokura, you should specify the charset you want in the content-type header.
$message['headers']['Content-Type'] = "text/plain; charset=UTF-8";
Thank you for your reply. My comment was not enough.
- Code of "$message['headers']['Content-Type'] = "text/html";" has worked OK with phpmailer_smtp 2.1.0. I noticed "charset=UTF-8" is added by someone.
- Code of "$message['headers']['Content-Type'] = "text/html";" doesn't work OK with phpmailer_smtp 2.2.3. I noticed "charset=UTF-8" should be added in the code as you mentioned.Today I have confirmed the patch does work for my website, so my information does not help at all. I'm sorry for your confusion.
- 🇮🇷Iran sgarsivaz
hi
I update this module to 2.2.3 and encountered with wrong encodings.
when I use " Test configuration " every thing are OK.
but for emails sent by update module, this is what happened :New release(s) available for ارزشیابی عملکرد کارکنان
and this is email header I can see :
X-Mailer: PHPMailer 6.9.1 (https://github.com/PHPMailer/PHPMailer)
sender: *************
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8BitSteps to reproduce :
1. drupal 9.5.11
2. some modules need update (drupal itself needs update to 10.1), set to daily consideration
3. phpmailer_smtp 2.2.3I don't known if it does matter, I also use queue_mail:1.6
- Status changed to Needs work
about 1 year ago 4:30pm 6 December 2023 - Status changed to Postponed: needs info
about 1 year ago 9:39pm 6 December 2023 - 🇦🇺Australia imclean Tasmania
OK I think I understand your situation. Aside from the test and update emails, does your website send out any other notifications?
What happens when you set the format to HTML in Configuration -> System -> PHPMailer SMTP -> Form (/admin/config/system/phpmailer-smtp/format)
- Status changed to Needs review
about 1 year ago 12:17am 7 December 2023 - 🇦🇺Australia imclean Tasmania
- 🇮🇷Iran sgarsivaz
thanks @imclean
I used these methods and problem goes away :
1. setting PHPMailer SMTP -> Format to HTML and it worked
2. setting PHPMailer SMTP -> Format to PlainText and using patch #20 and it workedwithout these two method, problem remains.
by the way, for your question, my website send out mails for user registration & update & webform ( by using queue_mail module) - Status changed to Fixed
about 1 year ago 9:39pm 7 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.