I haven't tried this stuff out but I've had a fairly good look at 3 of these PHP email scripts - three besides the one you were working on. From that I can tell that embedding the base 64 is the way to go, yet it's more complicated than what I at first suggested. Of the various PHP scripts I was looking at this one looks the easiest to use:
http://www.phpclasses.org/package/36...tachments.html
It's free, but requires a simple registration to download it. I think you might actually be happier with it. Two snippets (first from the main script page, the part you configure):
PHP Code:
#add image to be embeded
$img1 = $sec->embed('php-power-white.gif');
Easy to just enter the relative url to your image. And the main function on the include that does the heavy lifting and ties it in with the rest of the email in the correct manner:
PHP Code:
function embed($file) {
if(is_file($file)) {
$basename = basename($file);
$fileinfo = pathinfo($basename);
$contentid = md5(uniqid(time())).".".$fileinfo['extension'];
$embedheader = "--{$this->emailboundary}\r\n";
$embedheader .= "Content-Type: ".$this->mime_type($file)."; name=\"{$basename}\"\r\n";
$embedheader .= "Content-Transfer-Encoding: base64\r\n";
$embedheader .= "Content-Disposition: inline; filename=\"{$basename}\"\r\n";
$embedheader .= "Content-ID: <{$contentid}>\r\n\r\n";
$embedheader .= chunk_split(base64_encode(fread(fopen($file,"rb"),filesize($file))),72)."\r\n";
$this->embed[] = $embedheader;
return "<img src=3D\"cid:{$contentid}\">";
} else {
die('The File '.$file.' does not exsist.');
}
}
Now of course that won't work just on its own. It does show more or less how a proper cid is created (at least what's involved) and used with the base 64 embed. What you had was close, but lacked certain real time parts of the process and the direct linkage to the email, possibly even lacked proper placement for some of the parts, and had no provision for generating the base 64 code. Even with the above operating in its full code you would need GD or at least base64_encode (which might not require GD, not sure - most PHP comes with GD anyway).
I'm still not convinced this will work in all email clients. But I suspect it will work in more than simply using the full url or embedding base 64 in the manner I had first suggested.
But if you're happy with what you have now, I'm not complaining.
Bookmarks