Issues

ZF-12445: Zend_Mail Header Bug for Linux Machines for ZF 2.0

Issue Type: Bug Created: 2012-10-17T15:31:38.000+0000 Last Updated: 2012-10-22T11:55:18.000+0000 Status: Closed Fix version(s): Reporter: Nikesh Hajari (nikeshhajari) Assignee: Frank Brückner (frosch) Tags: - Zend_Mail

  • zend_mail

Related issues: Attachments:

Description

Hello,

I have noticed an issue when sending e-mails the headers show up in the e-mail itself. I looked at the EOL character used in the Zend\Mail\Headers class (constant EOL = \r\n) which is perfectly for Windows, but when sending an e-mail with this line break I get the following output in the actual email:

Reply-To: My Test Email test@myemail.com

From: John Doe john@stuff.com

Hello

When the constant is changed to \n ONLY then the output shows up normal (Just Hello). In other words this \r character is causing the headers to show up as plain text in the message body.

My suggestion is to used the PHP_EOL constant so it is automatically adjusted for each platform automatically.

http://stackoverflow.com/questions/128560/…

Thanks, Nikesh

Comments

Posted by Nikesh Hajari (nikeshhajari) on 2012-10-17T16:31:50.000+0000

Hello,

I have figured out more.

Changing line 31 in Zend\Mail\Headers from:

const EOL = "\r\n";

TO

const EOL = PHP_EOL;

will successfully allow me to send e-mails without the above problem occuring.

The following code now works normally:

    $m = new \Zend\Mail\Message();
    $m->addFrom('test@me.com', 'Jane Doe')
      ->addTo('test@you.com', 'John Doe')
      ->setSubject('Test');


    $bodyPart = new \Zend\Mime\Message();

    $bodyMessage = new \Zend\Mime\Part($html);
    $bodyMessage->type = 'text/html';

    $bodyPart->setParts(array($bodyMessage));

    $m->setBody($bodyPart);

Currently, trying to figure out:

when adding ->setEncoding('UTF-8') and HTML message shows shows up as a mime-attachment.

-Nikesh

Posted by Nikesh Hajari (nikeshhajari) on 2012-10-17T16:49:08.000+0000

Figured It Out:

This code here correctly works (UTF-8, HTML E-mail)

$m = new \Zend\Mail\Message(); $m->addFrom('sam@test.edu', 'Sam John') ->addTo('john@test.edu', 'John Doe') ->setSubject('Test');

    $bodyPart = new \Zend\Mime\Message();

    $bodyMessage = new \Zend\Mime\Part($html);
    $bodyMessage->type = 'text/html';

    $bodyPart->setParts(array($bodyMessage));

    $m->setBody($bodyPart);
    $m->setEncoding('UTF-8');

NOTE: If the $m->setEncoding('UTF-8') is called BEFORE setting the body the message will not show up correctly.

Two things needs to be fixed:

  1. PHP_EOL compatibility across all systems
  2. You should be able to call setEncoding('UTF-8') at anytime before sending the e-mail.

Posted by Frank Brückner (frosch) on 2012-10-22T11:55:18.000+0000

Please report ZF2 issues at https://github.com/zendframework/zf2/issues

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