processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

Can't use cyrillic characters in WireMail from name and attachments name #1681

Open esl51 opened 1 year ago

esl51 commented 1 year ago

Short description of the issue

I can't use cyrillic characters in WireMail from name and attachments name.

Expected behavior

E-mail is received.

Actual behavior

E-mail is not received.

Optional: Screenshots/Links that demonstrate the issue

Your screenshots/links go here.

Optional: Suggestion for a possible fix

Your possible fix goes here.

Steps to reproduce the issue

This code is working as expected (e-mail received with attachment).

$m = $mail->new();
$m->to('your@email.com');
$m->from('noreply@' . wire('config')->httpHost);
$m->fromName('Galaxy partners');
$m->subject('Partners test');
$m->bodyHTML('<p>Test</p>');
$m->attachment(wire('config')->paths->root . 'tmp/test.pdf', 'Attachment.pdf');
return $m->send();

This code is not working as expected (e-mail did not received at all).

$m = $mail->new();
$m->to('your@email.com');
$m->from('noreply@' . wire('config')->httpHost);
$m->fromName('Партнёры по галактике');
$m->subject('Tecт от партнёров');
$m->bodyHTML('<p>Тест</p>');
$m->attachment(wire('config')->paths->root . 'tmp/test.pdf', 'Вложение.pdf');
return $m->send();

Setup/Environment

ryancramerdesign commented 1 year ago

@esl51 Testing here, I can duplicate the issue with the "from" name. Though no issues with cyrillic anywhere else, including the subject, attachment, body, which seems to work okay in testing here. This is testing with just plain WireMail. If I test with a WireMail module (WireMailMailgun in my case) then the fromName also works. I'm unsure if that's the result of some code in WireMailMailgun or something at the Mailgun service.

I'm not positive if the issue is in WireMail or the SMTP server, but am going to assume WireMail for now, since we are both seeing it. It would seem that the fromName needs some kind of different encoding beyond just quoted printable. I tried duplicating the encoding used for the subject, but that didn't help. I don't know for sure what the solution is, so am going to add a help-needed tag to this in case someone else knows. Thanks.

esl51 commented 1 year ago

I don't use any modules in this case. Tested the code on another server and there is no problem with attachments. But the problem with long "from" is also confirmed.

esl51 commented 1 year ago

I installed the WireMailPHPMailer module and everything worked. Perhaps you should see how this point is implemented in PHPMailer.

BitPoet commented 1 year ago

Editing my earlier comment: there's just an issue of line wrapping at the correct spot. Shouldn't be that hard to fix. I'll give it a try.

BitPoet commented 1 year ago

There's an updated WireMail.php here in my processwire-wiremail fork. I want to test it a little more before I feel comfortable creating a pull request, but the first tests look promising. If anybody wants to give it a spin, feel free.

I rewrote a little more than initially thought. Encoding and wrapping should now work correctly for from:, to: and reply-to:.