Corrected string writing with Zend Framework 2

I dont understand how to parse raw email from ZF2?

In ZF1 it was:

$emailObj = new Zend_Mail_Message(array('raw' => $str_email));

      

And that was okay for me!

It should now be:

$emailObj = Zend\Mail\Message::fromString($str_email);

      

or

$emailObj = new Zend\Mail\Storage\Message(array ('raw' => $str_email));

      

or perhaps:

$emailObj = Zend\Mime\Message::createFromMessage($str_email, $boundary);

      

But none of this works for me!

+3


source to share


2 answers


Just tested with the latest version of Zend Framework 2 after facing the same problem. This works now, at least:



$mail = new Zend\Mail\Storage\Message(array('raw' => $content));

      

0


source


I am currently using ZF 2.5 via Composer. When i do

$emailObj = Zend\Mail\Message::fromString($str_email);

      



It works great for me. This is my working code.

    // Create a Zend\Mail\Message object with our message
    $email = \Zend\Mail\Message::fromString($src);

    // Create our transport
    $transport = new \Zend\Mail\Transport\Smtp();
    $options = new \Zend\Mail\Transport\SmtpOptions(array(
        'host' => $this->_opts['smtp_server'],
    ));
    $transport->setOptions($options);
    $transport->send($email);

      

0


source







All Articles