I'm having an issue when using PEAR with
$smtp = Mail::factory ('smtp', $params);
to redirect the smtp through a custom email server AND adding an attachment (several in fact), which appears to not be possible.
$HeadersCO = array (
'From' => $From,
'Return-path' => $From,
'To' => $Email,
'Subject' => $Subject2C,
'Reply-To' => $From,
'Date' => date("r"),
'Errors-To' => $Admin_Email,
'Return-Path' => $Company,
'X-Mailer' => "PHP v".phpversion(),
'X-Domain' => $SERVER_NAME,
'X-Page' => $PHP_SELF,
'Content-type' => $contentUTF8,
'MIME-Version' => $mime);
$mimeCO = new Mail_mime(array('eol' => $crlf));
$mimeCO->setTXTBody($textcontent); //Text version
$mimeCO->setHTMLBody($message); //HTML version
$imgNo=0;
while ($imgNo < $totalImages) {
$imageAtt = $imgarr[$imgNo];
$mimeCO->addAttachment($imageAtt, 'image/jpg');
$imgNo++;
}
$bodyCO = $mimeCO->get();
$hdrsCO = $mimeCO->headers($HeadersCO);
$mail2C = $smtp->send($email, $hdrsCO, $bodyCO);
This will send out an email to the correct email server with embedded images, but no attached images. The $mimeCO->addAttachment($imageAtt, 'image/jpg');
appears to not work at all, even if I create just one attachment with a specific file.
I read somewhere that when using PEAR mime & mail you can either redirect your emails to different SMTP service or add attachments, but not both. Is this correct? If it is, then that would explain why I'm having an issue with sending attachments using $smtp->send
in PEAR.