Issues

ZF2-177: Zend\Mail\Transport\Sendmail sends duplicate Subject due to adding header and use of mail function

Issue Type: Bug Created: 2012-02-25T13:56:49.000+0000 Last Updated: 2012-04-25T15:46:45.000+0000 Status: Resolved Fix version(s): Reporter: Mario Dees (mariod) Assignee: Ralph Schindler (ralph) Tags: - Zend\Mail

Related issues: Attachments:

Description

The subject is being added as a header, but also passed in the mailHandler via the php mail function and results in duplicate Subject displayed (at least in Mail in OSX)

protected function prepareHeaders(Message $message)
{
    $headers = $message->headers();

    // On Windows, simply return verbatim
    if ($this->isWindowsOs()) {
        return $headers->toString();
    }

    // On *nix platforms, strip the "to" header
    $headersToSend = new Headers();
    foreach ($headers as $header) {
        if ('To' == $header->getFieldName()) {
            continue;
        }        
        $headersToSend->addHeader($header);
    }
    return $headersToSend->toString();
}

should become:

protected function prepareHeaders(Message $message)
{
    $headers = $message->headers();

    // On Windows, simply return verbatim
    if ($this->isWindowsOs()) {
        return $headers->toString();
    }

    // On *nix platforms, strip the "to" header
    $headersToSend = new Headers();
    foreach ($headers as $header) {
        if ('To' == $header->getFieldName()) {
            continue;
        }
        if ('Subject' == $header->getFieldName()) {
            continue;
        }            
        $headersToSend->addHeader($header);
    }
    return $headersToSend->toString();
}

Comments

Posted by Evan Coury (evan.pro) on 2012-04-25T15:46:45.000+0000

Fixed with PR 1034.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts