[ACCEPTED]-PHPMailer, AddStringAttachment and Data URI Scheme-phpmailer

Accepted answer
Score: 18

It turns out I needed to strip the data:image/png;base64, section 1 and base64_decode() the data:

$data = substr($contact_image_data, strpos($contact_image_data, ","));
$encoding = "base64"; 
$type = "image/png";
$mail->AddStringAttachment(base64_decode($data), $filename, $encoding, $type);          
Score: 2

Yes it should be possible. Are you calling 6 toDataURL() with the 'image/png' MIME type 5 so it knows how to output it?

Try breaking 4 your script into two components - make sure 3 you really have a PNG then try mailing it.

For 2 example, will test.png open on your computer 1 when written?..

$fp = fopen('test.png', 'w');
fwrite($fp, $contact_image_data);

Hope that helps a bit!

More Related questions