Hi All,

I'm trying to use Zend_Mail to add an attachment that is then referenced as a background image in an HTML email but I can't seem to get it to move beyond a simple attachment.

From my research thus far, it seems the Content-Type header is not set the same as when e.g. Outlook Express does it. I've managed to get the rest of the boundary stuff to be similar to how OE does it but not this header - this may be totally wrong of course and I've missed something else altogether!

e.g. Zend_Mail version:

Content-Type: multipart/mixed; charset="iso-8859-1";
boundary="=_c0f35f550a46c83519a39ac127745f09"

and Outlook Express version:

Content-Type: multipart/related;
   type="multipart/alternative";
   boundary="----=_NextPart_000_0006_01C73019.4DB76A10"

How can I set this correctly (e.g. with multipart/related etc.) with Zend_Mail or has anyone got a simple way to solve my issue?

Here's what I have so far:

$mail                = new Zend_Mail();
...
$bg_image       = file_get_contents('myfile.jpg');

$bg = $mail->addAttachment($bg_image, 'image/jpeg;
       name="email_lh_background.jpg"', false, Zend_Mime::ENCODING_BASE64);

$msg_time        = time();
$bg->id            = $msg_time . '@' . $msg_time;

$html_body = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<HTML xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
<HEAD>
</HEAD>
<BODY background=cid:' . $bg->id . '>
Email content
</BODY>
</HTML>';

$mail->setBodyHtml($html_body);
...
$mail->send();

Thanks for any help,
Jeremy

Reply via email to