A shot in the dark but this might be it:
$data = chunk_split(base64_encode(join('', file($filelocation))));
Which is the literal image itself in a binary data stream reattached to the mail content. And which I forgot to add to the $content variable after "Content-Disposition" line and before the mime boundary.
In the original configuration the binary image data stream is added after the "Content-Transfer-Encoding" line and would exist in the email, but it would exist mangled (see the commented out lines of code), so I substituted those lines with lines from a script I found elsewhere, and now you see nothing because the binary image data stream was accidentally left out.
I am theorizing the above-mentioned line might be the problem: in other words, the binary image data stream itself is the problem. In theory, I could test doing this:
$data = chunk_split(base64_encode(join('', file($filelocation))));
$ext = substr($filelocation, strrpos($filelocation, '.') + 1, strlen($filelocation));
$fileID = @fopen("blah.$ext", 'wb');
if ($fileID) {
@fputs($fileID, $data);
@fflush($fileID);
@fclose($fileID);
clearstatcache();
}
And then just check to see what the "blah" image looks like; if it looks mangled, then the email content headers are not mangled, the data is!
Would that be the best approach or are you thinking something else?
Phil