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

Subject header is duplicated #72

Closed
michalbundyra opened this issue Jan 15, 2020 · 3 comments · Fixed by #103
Closed

Subject header is duplicated #72

michalbundyra opened this issue Jan 15, 2020 · 3 comments · Fixed by #103
Labels
Bug Something isn't working Help Wanted

Comments

@michalbundyra
Copy link
Member

Summary
On Windows with PHP 7, when sending an mail message with the Sendmail transport, the subject header is duplicated.

Steps to reproduce
To reproduce the bug the sample from here can be used:
http://framework.zend.com/manual/current/en/modules/zend.mail.introduction.html

The resulting mail headers look something like this:
Subject: Test Subject
Date: Wed, 29 Jul 2015 17:33:17 +0000
From: =?UTF-8?Q?test?= [email protected]
To: [email protected]
Subject: Test Subject

Cause
In the Sendmail transport all headers (including the Subject) and the subject itself are passed to the php mail function:
$result = mail($to, $subject, $message, $headers);
The mail function then appends to the $subject to the $headers. I do not think the php mail function should handle this case because it doesn't know what subject the caller intended to use. However I believe php mail should at least issue a warning (TBD: file enhancement at https://bugs.php.net/).

Solution
Pass the headers without the Subject header to the php mail function. This is already done if the os is not Windows in the prepareHeaders. I think it should be done for Windows as well.


Originally posted by @matbech at zendframework/zend-mail#22

@michalbundyra michalbundyra added Bug Something isn't working Help Wanted Test labels Jan 15, 2020
@michalbundyra
Copy link
Member Author

I was not able to reproduce this error. It seems, it is fixed in the current version.

Successfully tested on Windows 10 Pro with php-7.1.26-Win32-VC14-x64, php-7.2.15-Win32-VC15-x64 and php-7.3.2-Win32-VC15-x64.

Used quickstart example for Sendmail Transport Usage

use Zend\Mail\Message;
use Zend\Mail\Transport\Sendmail as SendmailTransport;

$message = new Message();
$message->addTo('[email protected]');
$message->addFrom('[email protected]');
$message->setSubject('Greetings and Salutations!');
$message->setBody("Sorry, I'm going to be late today!");

$transport = new SendmailTransport();
$transport->send($message);

Received mail

Date: Tue, 05 Mar 2019 08:50:08 +0100
From: [email protected]
To: [email protected], [email protected]
Subject: Greetings and Salutations!, Greetings and Salutations!

Sorry, I'm going to be late today!

Edit: zend-mail v2.10.0


Originally posted by @arueckauer at zendframework/zend-mail#22 (comment)

@michalbundyra
Copy link
Member Author

But why is To duplicated in your test result?

And for clarity include the value of your current zend-mail version.


Originally posted by @glensc at zendframework/zend-mail#22 (comment)

@michalbundyra
Copy link
Member Author

Very good observation, I will have a look into it. This might be a new issue.


Originally posted by @arueckauer at zendframework/zend-mail#22 (comment)

@michalbundyra michalbundyra removed the Test label Mar 2, 2020
samsonasik added a commit to samsonasik/laminas-mail that referenced this issue Aug 5, 2020
@samsonasik samsonasik linked a pull request Aug 5, 2020 that will close this issue
artemii-karkusha pushed a commit to artemii-karkusha/laminas-mail that referenced this issue May 24, 2023
artemii-karkusha pushed a commit to artemii-karkusha/laminas-mail that referenced this issue May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Help Wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant