The PEAR Mail_Mime package is what you do here.
Once you customize your message, adding an attachment will be as simple as:
$mime = new Mail_mime("\n"); $mime->setTXTBody($msg_text); $mime->setHTMLbody($msg_html); // Add gif as attachment to mail $mime->addAttachment("/path/to/image/smile.gif", "image/gif"); $body = $mime->get(); $headers = $mime->headers($headers); $mail->send(" joe@bloggs.com ", $headers, $body);
If you are looking for your logo to display in a specific place in the letter, and not just as an attachment, you can do the following:
// In your message html: <img src='logo.gif' alt='Our logo' /> // PHP: $mime->addHTMLImage('/path/to/image/logo.gif');
This approach may have mixed results depending on your user mail client, so before sending it, try checking your format on dummy gmail, yahoo and hotmail accounts.
Conroyp
source share