Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raw string email with Zend Framework 2

I don't understand how to parse raw email with ZF2?

In ZF1 it was:

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

And it was ok for me!

Now it should be:

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

or

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

or maybe:

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

But nothing of these does not work for me!

like image 407
newtonrus Avatar asked Aug 12 '26 07:08

newtonrus


1 Answers

I'm currently using ZF 2.5 via Composer. When I do

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

It works perfectly 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);
like image 113
angrychimp Avatar answered Aug 14 '26 12:08

angrychimp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!