Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- When using PEAR's Mail_Mime, the text portion doesn't work when attaching HTML images
- //Headers
- $headers['From'] = "from@address.com";
- $headers['To'] = "to@address.com";
- $headers['Subject'] = "A MIME Email";
- //Text Portion
- $text = "This is the text portion.";
- //HTML Portion
- $html = "<html><body><p><img src='image.png' />This is the HTML portion.</p></body></html>";
- //Set up the MIME email
- $mime = new Mail_mime(array('eol' => "rn"));
- $mime->setTXTBody($text);
- $mime->setHTMLBody($html);
- $mime->addHTMLImage("/path/to/image.png", "image/png");
- //Prepare the message to be sent
- $body = $mime->get();
- $headers = $mime->headers($headers);
- //Send the message via SMTP
- $mail_obj =& Mail::factory('smtp', array('host' => 'smtp.server.com', 'port' => 25));
- $mail_obj->send("to@address.com", $headers, $body);
- Date: Thu, 26 May 2011 10:39:24 -0500 (CDT)
- From: From Address <from@address.com>
- Subject: A MIME Email
- To: to@address.com
- Message-id: <20110526153924.0C12120697@smtp.server.com>
- MIME-version: 1.0
- Content-type: multipart/alternative;
- boundary="=_e107860f353617028a0059317ce51c1f"
- Original-recipient: rfc822;to@address.com
- --=_e107860f353617028a0059317ce51c1f
- Content-Transfer-Encoding: quoted-printable
- Content-Type: text/plain;
- charset=ISO-8859-1
- This is the text portion.
- --=_e107860f353617028a0059317ce51c1f
- Content-Type: multipart/related;
- boundary="=_52fd7475fcf0abd310b6a38cd33f5c46"
- --=_52fd7475fcf0abd310b6a38cd33f5c46
- Content-Transfer-Encoding: quoted-printable
- Content-Type: text/html;
- charset=ISO-8859-1
- <html><body><p><img src='cid:3c0db5d0a50b8752771f64048f527338' />This is th=
- e HTML portion.</p></body></html>
- --=_52fd7475fcf0abd310b6a38cd33f5c46
- Content-Transfer-Encoding: base64
- Content-ID: <3c0db5d0a50b8752771f64048f527338>
- Content-Type: image/png;
- name=background.png
- Content-Disposition: inline;
- filename=background.png
- iVBORw0KGgoAAAANSUhEUgAAAAEAABOICAYAAABwnAfKAAAAkUlEQVR42u3WSwrAIAwFwND7X9d1
- eoHSb9TSzmYQSV5AXCRaa7lEROySJ+8uFd+8q2l73FEdkJNSRgR07q0uuVncJWBY6I9OWy85bKRB
- 7xo04TN8/vTO0OriziWFvcMCJqTMCui8rj5fuyMz43i1BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- AAAAAAAAAIB/swItzir5J/ImiQAAAABJRU5ErkJggg==
- --=_52fd7475fcf0abd310b6a38cd33f5c46--
- --=_e107860f353617028a0059317ce51c1f--
Add Comment
Please, Sign In to add comment