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

UTF-8 texts are received and displayed incorrectly #96

Closed
enzy opened this issue Feb 23, 2018 · 15 comments
Closed

UTF-8 texts are received and displayed incorrectly #96

enzy opened this issue Feb 23, 2018 · 15 comments
Assignees
Labels

Comments

@enzy
Copy link

enzy commented Feb 23, 2018

Sample email as received and saved by Papercut:
https://www.dropbox.com/s/wn7o2lpx3tnpb77/20180223123256925-000e8a.eml?dl=0

image

Generated by PHP Nette Framework backend.

And here is how it looks when sent on server (Mailgun service) to Gmail:
https://www.dropbox.com/s/bh5yg6lks7wbg5l/original_msg.eml?dl=0 (removed irrelevant server headers)

image

Papercut v5.1.3, Windows 10 x64

@mklusak
Copy link

mklusak commented Mar 3, 2018

Same problem, for months. Everything works on-line, only emails sent on localhost are like this:

obrazek 17

@geminorum
Copy link

geminorum commented Mar 3, 2018

If you use php mailer, I suggest this on dev environment: $phpmailer->Encoding = 'quoted-printable';

@mklusak
Copy link

mklusak commented Mar 4, 2018

Yes, I use PHPMailer as part of "vanilla" WordPress. Default encoding is 8bit. Quoted-printable works. Still, I'm surprised it does not work with default settings.

@ve3
Copy link

ve3 commented Mar 12, 2018

Confirm this problem.
I use this email code in php.

<?php
$headers =  'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'From: [email protected]' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

$message = '<h3>Lorem ipsum ภาษาไทย</h3>';
$message .= '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer convallis leo ut sollicitudin commodo. Nullam accumsan libero ut justo vestibulum porta. Nulla mi lectus, ornare eu laoreet nec, tincidunt pretium risus. Maecenas commodo, ipsum at consectetur malesuada, lectus dui feugiat augue, eu sollicitudin metus lorem at neque. Proin hendrerit, enim quis consectetur laoreet, mauris enim efficitur risus, vel ullamcorper dolor turpis sit amet sapien. Mauris vel orci eu leo mollis laoreet non eget magna. Nunc sed pulvinar metus, vel placerat massa. Aenean arcu mauris, elementum nec rutrum nec, scelerisque in nisl. Proin tempor, ante egestas semper rutrum, ante ligula dapibus lectus, eu sollicitudin augue quam sit amet arcu. Proin id ornare enim. Sed tincidunt lobortis mi non condimentum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer sed ligula magna. Aenean a aliquet justo.</p>';
$message .= '<p>Phasellus dui tellus, tempor ut sollicitudin at, laoreet sed enim. Suspendisse justo lectus, pretium eu orci eu, condimentum iaculis turpis. Sed lobortis placerat justo, vel porta mauris fringilla ut. Aliquam erat volutpat. Maecenas at quam non elit auctor tempus. Nulla accumsan lobortis dui, vitae vulputate justo hendrerit a. Aenean in purus lacus. Phasellus sit amet egestas nisl. Curabitur non sapien sem. Duis posuere risus mauris, ac aliquam nibh congue volutpat. Maecenas gravida euismod mi, id fermentum magna vehicula molestie. Nunc rutrum augue id elit tempus ultrices. Nullam aliquet dolor enim, luctus pretium leo blandit eget. Proin placerat eros vitae libero porttitor, vel aliquam felis varius. Aenean neque mauris, hendrerit id purus elementum, maximus faucibus leo. Praesent ut felis vel lectus consequat posuere nec eu massa.</p>';
$message .= '<img src="https://i.imgur.com/aP3KVeX.jpg" alt="" width="700">';
$message .= '<table width="100%">
		<tr>
			<td style="padding: 5px; vertical-align: top;">
				<p>Quisque eu purus vulputate, facilisis ex sit amet, faucibus nisi. Ut sed justo velit. Nulla nec scelerisque nulla. Donec sem turpis, placerat in gravida vitae, fermentum ac enim. Cras in mi tempor, malesuada velit volutpat, gravida mi. Sed varius felis a magna rutrum, ac congue nulla eleifend. Vivamus ut diam sed est consequat molestie aliquam eu nulla. Proin bibendum maximus nulla. Proin molestie, arcu a elementum commodo, odio nisi ultricies orci, suscipit lacinia justo orci at ligula. Phasellus libero mauris, porta quis diam vel, eleifend imperdiet arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla consectetur efficitur massa ac sagittis. Donec sit amet bibendum felis. Donec risus mauris, ornare eget nunc vel, consequat venenatis dui. Donec nisl neque, elementum vel ex vitae, convallis pellentesque magna. Suspendisse id dolor ut orci finibus luctus.</p>
				<p>Aenean vel velit augue. Donec id velit in elit iaculis pharetra et id ipsum. Donec id lobortis velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed sed nisi bibendum, ultricies quam a, consequat tellus. Vestibulum sit amet velit eu justo lacinia interdum. Quisque gravida orci sit amet ultricies vulputate. Nunc sed sodales nisi, at bibendum neque. Nam consequat scelerisque ipsum, eu maximus urna. Etiam lectus libero, pulvinar eget hendrerit at, fringilla at nunc. Etiam aliquam purus vitae est sollicitudin, et sagittis dui tincidunt.</p>
			</td>
			<td style="padding: 5px; vertical-align: top;">Ut eget consequat enim. Nulla non cursus risus, eget dapibus ipsum. Curabitur porttitor ultricies tellus, euismod ornare sem interdum id. Sed luctus augue ut mi molestie, vitae interdum dolor vehicula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut porta, massa vitae iaculis accumsan, sapien sem ullamcorper velit, sed accumsan nunc massa ac ante. Vivamus blandit ut tortor vel mollis. Curabitur at sodales odio. Proin et ante eu magna vestibulum tincidunt non in metus. Nulla facilisi.</td>
		</tr>
	</table>';

$result = mail('[email protected]', 'Using Papercut to capture email!', $message, $headers);

var_dump($result);

The first line should displaying Lorem ipsum ภาษาไทย. But it is currently displaying Lorem ipsum ??????? (please look at blue highlight in the content.

papercut_2018-03-12_13-26-04

@jorrit
Copy link
Contributor

jorrit commented Apr 4, 2018

8bit only works when the SMTP server supports sending the 8BITMIME or SMTPUTF8 SMTP extensions, see SendSmtpCommand.cs:

Session.UseUtf8 = anyEncoding.Contains("8BITMIME") || anyEncoding.Contains("SMTPUTF8");
Connection.Encoding = Session.UseUtf8 ? Encoding.UTF8 : Encoding.ASCII;

The PHP SMTP client on Windows doesn't support this. My mails are mostly ASCII and knowing that when the code is deployed to a Linux server, it works, it's not a big priority for me. However, for mails that are mostly non-ASCII, like ภาษาไทย., this is a big problem.

I see two solutions to this:

  1. Add a setting that allows the user to set the default encoding to UTF-8 regardless of the SMTP extensions.
  2. Papercut could support Content-Transfer-Encoding by setting the connection encoding from ASCII to UTF-8 whenever it sees 8bit for the body of the message. So this means that there is a separate header encoding and body encoding.

@jijiechen
Copy link
Collaborator

Could you use "Base64" or "Quoted-printable" as content transfer encoding? Both of them work.

@jorrit
Copy link
Contributor

jorrit commented Apr 4, 2018

Unfortunately, I am using Drupal, which forces the use of CTE=8bit.

@enzy
Copy link
Author

enzy commented Apr 4, 2018

Could you use "Base64" or "Quoted-printable" as content transfer encoding? Both of them work.

As this is a development SMTP server I don't want to change any settings used for production setup. Which used encoding is and works fine on production.

@stale
Copy link

stale bot commented Feb 6, 2019

Aloha! I'm ScissorBot ✂️ -- the bot in charge of keeping the issues tidy. It looks like this issue is stale due to lack of activity. Unfortunately, I'll be closing it if there is no further activity. 😞 Please contribute to the issue to keep it open. Thanks!

@stale stale bot added the wontfix label Feb 6, 2019
@enzy
Copy link
Author

enzy commented Feb 7, 2019

This is still an issue.

@stale stale bot removed the wontfix label Feb 7, 2019
@ghost
Copy link

ghost commented Feb 7, 2019

I am using Windows 10 environment and my php mail() function with all utf-8 headers , as well as html body code is there but papercut still shows turkish characters in utf-8 charset as "??????????".

The same script shows correct characters when I test on Mailslurper which is another stmp simulator on my computer.

Any workaround this ?

@Jaben Jaben added the bug label Feb 11, 2019
@Jaben
Copy link
Member

Jaben commented Feb 11, 2019

Should have a fix for this soon.

@Jaben
Copy link
Member

Jaben commented Feb 28, 2019

Fixed in latest dev.

@Jaben Jaben closed this as completed Feb 28, 2019
@necromind
Copy link

Fixed in latest dev.

How to download Papercut 6.0 ? I cant see Cyrillic text in 5.5.1.

@Jaben
Copy link
Member

Jaben commented Mar 11, 2019

@necromind Please open a new issue if you are still having problems. Note that this will NOT change emails that have already been received. Verify that you cannot see Cyrillic text on NEW emails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants