I am sending emails using the Zend_Mail_Transport_Smtp
. The sending part works fine, however, I am struggling trying to copy the email to the 'Sent' folder of the sending email account. When generating the message from the Zend_Mail, I keep getting Call to a member function getContent() on a non-object.
Here is what I am doing:
$config = array(
'auth' => 'login',
'username' => $from,
'password' => $password);
$transport = new Zend_Mail_Transport_Smtp('smtp.123-reg.co.uk', $config);
Zend_Mail::setDefaultTransport($transport);
$mail = new Zend_Mail('utf-8');
$mail->addTo('foo@bar.com');
$mail->setSubject('Test');
$mail->setFrom('baz@bar.com', 'Baz');
$mail->setBodyText('This is the email');
$mail->send();
**$message = $mail->generateMessage(); <----- here is the problem**
*This is where I would append the message to the sent folder.*
$mail = new Zend_Mail_Storage_Imap
array('host' => 'imap.123-reg.co.uk',
'user' => 'baz@bar.com',
'password' => 'p'
));
$mail->appendMessage($message,'Sent');
I'm not sure if I am missing anything or doing this completely the wrong way. Any help would be great.