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

PHPMailer 6.1.4 fullwidth subject #1945

Closed
6 tasks done
yKanazawa opened this issue Jan 22, 2020 · 5 comments
Closed
6 tasks done

PHPMailer 6.1.4 fullwidth subject #1945

yKanazawa opened this issue Jan 22, 2020 · 5 comments

Comments

@yKanazawa
Copy link

yKanazawa commented Jan 22, 2020

Please check these things before submitting your issue:

  • Read the error message you're seeing - it often tells you what is wrong, and may contain useful links & instructions
  • Make sure you're using the latest version of PHPMailer
  • Check that your problem is not dealt with in the troubleshooting guide, especially if you're having problems connecting to Gmail or GoDaddy
  • Include sufficient code to reproduce your problem
  • If you're having an SMTP issue, include the debug output generated with SMTPDebug = 2 set
  • If you have a question about how to use PHPMailer (rather than reporting a bug in it), tag a question on Stack Overflow with phpmailer, but search first!

Problem description

Versions: later than 6.0.7

In the case of $this->Mailer = 'mail';,
it seems that full width subject encoding appears to be failing.

Code to reproduce

Test Code

<?php
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer();

$mail->SMTPDebug = 2;
$mail->isMail();
$mail->Host = '127.0.0.1';
$mail->Encoding = "7bit";
$mail->CharSet = 'ISO-2022-JP';

$mail->setFrom('[email protected]', mb_encode_mimeheader('FULLW-FROM'));
$mail->Subject = mb_encode_mimeheader('FULLW-SUBJECT');
$mail->Body = 'FULLW-BODY';

$mail->addAddress('[email protected]');

$mail->isHTML(false);
$mail->send();

PHPMailer 6.0.7
Subject: FULLW-SUBJECT

Received: by app.example.com (Postfix, from userid 1000)
	id 1A4B42E157A; Wed, 22 Jan 2020 18:21:34 +0900 (JST)
To: [email protected]
Subject: =?UTF-8?B?77ym77y177ys77ys77y377yN77yz77y177yi77yq77yl77yj77y0?=
X-PHP-Originating-Script: 0:PHPMailer.php
Date: Wed, 22 Jan 2020 18:21:34 +0900
From: =?UTF-8?B?77ym77y177ys77ys77y377yN77ym77yy77yv77yt?= <[email protected]>
Message-ID: <ReFYcsIbmzkYl7kzQVqcJHLhrcbf2KxJ5PHVYKu2k@app>
X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP

FULLW-BODY

PHPMailer 6.1.4
Subject: =?UTF-8?B?77ym77y177ys77ys77y377yN77yz77y177yi77yq77yl77yj77y0?=

Received: by app.example.com (Postfix, from userid 1000)
	id F32282E1579; Wed, 22 Jan 2020 18:18:07 +0900 (JST)
To: [email protected]
Subject: =?us-ascii?Q?=3D=3FUTF-8=3FB=3F77ym77y177ys77ys77y377yN77yz7?=  =?us-ascii?Q?7y177yi77yq77yl77yj77y0=3F=3D?=
X-PHP-Originating-Script: 0:PHPMailer.php
Date: Wed, 22 Jan 2020 18:18:07 +0900
From: =?UTF-8?B?77ym77y177ys77ys77y377yN77ym77yy77yv77yt?= <[email protected]>
Message-ID: <tGMMwDmGQjcmzuOcScE3gGXWoqqwYbZ7SR6ALGYE@app>
X-Mailer: PHPMailer 6.1.4 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP

FULLW-BODY

Debug output

@NiklasBr
Copy link
Contributor

Are you sure you need to encode the Subject? PHPMailer will do that for you, it looks like it is double-encoded in your above example.

@Synchro
Copy link
Member

Synchro commented Jan 22, 2020

Exactly; Don't do that!

@Synchro Synchro closed this as completed Jan 22, 2020
@yKanazawa
Copy link
Author

yKanazawa commented Jan 22, 2020

Test Code

<?php
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer();

$mail->SMTPDebug = 2;
$mail->isMail();
$mail->Host = '127.0.0.1';
$mail->Encoding = "7bit";
$mail->CharSet = 'ISO-2022-JP';

$mail->setFrom('[email protected]', mb_encode_mimeheader('FULLW-FROM'));
$mail->Subject = 'FULLW-SUBJECT';
$mail->Body = 'FULLW-BODY';

$mail->addAddress('[email protected]');

$mail->isHTML(false);
$mail->send();

PHPMailer 6.0.7
Subject: FULLW�SUBJECT (Garbled)

Received: by app.example.com (Postfix, from userid 1000)
	id 060B82E157C; Wed, 22 Jan 2020 18:44:49 +0900 (JST)
To: [email protected]
Subject: =?ISO-2022-JP?B?77ym77y177ys77ys77y377yN77yz77y177yi77yq77yl?=  =?ISO-2022-JP?B?77yj77y0?=
X-PHP-Originating-Script: 0:PHPMailer.php
Date: Wed, 22 Jan 2020 18:44:49 +0900
From: =?UTF-8?B?77ym77y177ys77ys77y377yN77ym77yy77yv77yt?= <[email protected]>
Message-ID: <S2z4zWDZqx0CoGtZpN1V9FLbZsCiZmqVRwYw77Z8Mo@app>
X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP

FULLW-BODY

PHPMailer 6.1.4
Subject: FULLW�SUBJECT (Garbled)

Received: by app.example.com (Postfix, from userid 1000)
	id 695E32E157D; Wed, 22 Jan 2020 18:47:12 +0900 (JST)
To: [email protected]
Subject: =?ISO-2022-JP?B?77ym77y177ys77ys77y377yN77yz77y177yi77yq77yl?=  =?ISO-2022-JP?B?77yj77y0?=
X-PHP-Originating-Script: 0:PHPMailer.php
Date: Wed, 22 Jan 2020 18:47:12 +0900
From: =?UTF-8?B?77ym77y177ys77ys77y377yN77ym77yy77yv77yt?= <[email protected]>
Message-ID: <SDl3fAX8v2DaSC96tZL7HzBZc97Q0BLbrBOegJnLEY@app>
X-Mailer: PHPMailer 6.1.4 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP

FULLW-BODY

@yKanazawa
Copy link
Author

yKanazawa commented Jan 22, 2020

Test Code

<?php
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer();

$mail->SMTPDebug = 2;
$mail->isMail();
$mail->Host = '127.0.0.1';
$mail->Encoding = "7bit";
$mail->CharSet = 'UTF-8';

$mail->setFrom('[email protected]', mb_encode_mimeheader('FULLW-FROM'));
$mail->Subject = 'FULLW-SUBJECT';
$mail->Body = 'FULLW-BODY';

$mail->addAddress('[email protected]');

$mail->isHTML(false);
$mail->send();

PHPMailer 6.0.7
Subject: FULLW-SUBJECT

Received: by app.example.com (Postfix, from userid 1000)
	id AB00A2E1580; Wed, 22 Jan 2020 18:59:21 +0900 (JST)
To: [email protected]
Subject: =?UTF-8?B?77ym77y177ys77ys77y377yN77yz77y177yi77yq77yl77yj77y0?=
X-PHP-Originating-Script: 0:PHPMailer.php
Date: Wed, 22 Jan 2020 18:59:21 +0900
From: =?UTF-8?B?77ym77y177ys77ys77y377yN77ym77yy77yv77yt?= <[email protected]>
Message-ID: <Rfb1EpNhenkR4trhFX2YKxiUVnBqvueqVHtfWCfOu4@app>
X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8

FULLW-BODY

PHPMailer 6.1.4
Subject: FULLW-SUBJECT

Received: by app.example.com (Postfix, from userid 1000)
	id AD1802E157F; Wed, 22 Jan 2020 18:57:20 +0900 (JST)
To: [email protected]
Subject: =?UTF-8?B?77ym77y177ys77ys77y377yN77yz77y177yi77yq77yl77yj77y0?=
X-PHP-Originating-Script: 0:PHPMailer.php
Date: Wed, 22 Jan 2020 18:57:20 +0900
From: =?UTF-8?B?77ym77y177ys77ys77y377yN77ym77yy77yv77yt?= <[email protected]>
Message-ID: <ezNu7ngZK06RCVmF6gkH5FNTD3UZT2ZJmWiGRU3Evjk@app>
X-Mailer: PHPMailer 6.1.4 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8

FULLW-BODY

@Synchro
Copy link
Member

Synchro commented Jan 22, 2020

Don't do this:

$mail->setFrom('[email protected]', mb_encode_mimeheader('FULLW-FROM'));

Just do this:

$mail->setFrom('[email protected]', 'FULLW-FROM');

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