Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Subject header is duplicated #22

Open
matbech opened this issue Jul 29, 2015 · 4 comments
Open

Subject header is duplicated #22

matbech opened this issue Jul 29, 2015 · 4 comments

Comments

@matbech
Copy link

matbech commented Jul 29, 2015

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.

matbech added a commit to matbech/zend-mail that referenced this issue Jul 29, 2015
Remove the subject header otherwise it will be duplicated.
@matbech matbech mentioned this issue Sep 13, 2015
@arueckauer
Copy link

arueckauer commented Mar 5, 2019

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

@glensc
Copy link
Contributor

glensc commented Mar 5, 2019

But why is To duplicated in your test result?

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

@arueckauer
Copy link

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

@michalbundyra
Copy link
Member

This repository has been closed and moved to laminas/laminas-mail; a new issue has been opened at laminas/laminas-mail#72.

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

No branches or pull requests

5 participants