-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Message->setBody
sets Content-Type but keeps parameters such as charset
#265
Comments
Also I just noticed that |
If transformative encoding is set on the first part like so: $mailMessage1 = new Laminas\Mail\Message();
$mailMessage2 = new Laminas\Mail\Message();
$mimeMessage = new Laminas\Mime\Message();
$mimeMessage->addPart((new Laminas\Mime\Part('part one'))->setType('text/plain')->setCharset('UTF-8')->setEncoding(Laminas\Mime\Mime::ENCODING_BASE64));
$mailMessage1->setBody($mimeMessage);
$mimeMessage->addPart((new Laminas\Mime\Part('part two'))->setFileName('attachment.txt')->setDisposition(Laminas\Mime\Mime::DISPOSITION_ATTACHMENT));
$mailMessage1->setBody($mimeMessage);
$mailMessage2->setBody($mimeMessage);
$transport = new Laminas\Mail\Transport\File(new Laminas\Mail\Transport\FileOptions(['path' => '/tmp', 'callback' => function() {return 'mail1.log';}]));
$transport->send($mailMessage1);
$transport->getOptions()->setCallback(function() {return 'mail2.log';});
$transport->send($mailMessage2);
Basically calling |
I think simply adding $this->clearHeaderByName('content-type');
$this->clearHeaderByName('content-transfer-encoding'); before this line would pretty much solve it. |
It is undesirable for these headers to remain from a previous single-part call. Solves laminas#265 Signed-off-by: Karel Vlk <[email protected]>
Bug Report
Summary
If a
Mail\Message
had a single-part body previously andsetBody()
is called again with a multi-partMime\Message
, theContent-Type
gets changed tomultipart/mixed
but the additionalparameters
such ascharset
are kept. I don't thinkcharset
is allowed onmultipart/mixed
or at least it doesn't make much sense.Current behavior
How to reproduce
Note that
mailMessage2->setBody
was only called at the end and has therefore nocharset
whereasmailMessage1->setBody
was also called intermediately and hascharset="UTF-8"
set.Expected behavior
The text was updated successfully, but these errors were encountered: