PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #5201

Mail_Mime: addHTMLImage not determining attachment Content-Type

Details

Submitted2005-08-24 21:59 UTC
Fromjohn dot draughn at gmail dot com
Assignedcipri
StatusWont fix
PackageMail_Mime
PHP Version5.0.4
OSLinux - Fedora Core 4
Roadmaps(Not assigned)

Comments

[2005-08-24 21:59 UTC] john dot draughn at gmail dot com

Description:
------------
Mail 1.1.8 (stable)
Mail_Mime 1.3.1 (stable)
PEAR 1.3.6 (stable)

Mail_mime::addHTMLImage does not correctly identify png images. Succeeds in attaching image but with content-type of "application/octet-stream" instead of "image/png"

Test script:
---------------
require_once("Mail.php");
require_once("Mail/mime.php");
$message = new Mail_mime("\n");
$message->setTXTBody("Test Text Body\n\n\n");
$message->setHTMLBody("<html><body><img src=\"test.png\" /><br />Test HTML Body</body></html>");
$res = $message->addHTMLImage("test.png");
if(PEAR::isError($res)) {
die($res->getMessage());
}
$body = $message->get();
$headers = $message->headers(array("To"=>"you@yourdomain.com", "From"=>"me@mydomain.com", "Subject"=>"Test addHTMLImage()"));
$mObj =& Mail::factory("smtp", array("host"=>"smtp.mydomain.com"));
if(PEAR::isError($mObj)) {
die($mObj->getMessage());
}
$response = $mObj->send("you@yourdomain.com", $headers, $body);
if(PEAR::isError($response)) {
die($response->getMessage());
}

Expected result:
----------------
I expected the addHTMLImage method to properly determine the image type and attach with the appropriate content-type defined.

Actual result:
--------------
addHTMLImage attached the image but with an incorrect content-type of "application/octet-stream"

*NOTE*
This method works when you EXPLICITLY specify the content-type as the second parameter.