DanPride
DanPride

Reputation: 150

Sending inline email attachments on Google App Engine Php

How do you do an in-line image embed in appengine php? Does it need to be base64? I see the $message->addAttachment but how do I reference it inside the html that I am assembling?

With swiftmailer I would just

$SMap = PUBLIC_ROOT . "images/sample.jpg";
$type = pathinfo($SMap, PATHINFO_EXTENSION);
$data = file_get_contents($SMap);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
$ImageCode = "<img style=\"padding:0 50px 0 0;\" src=\"" . $base64 .     "\" alt=\"Image\" />";

and just insert the image display code where I wanted it, but I don't see any reference material on this or I can't locate it for some reason for php appengine native email.

Upvotes: 0

Views: 179

Answers (1)

Sriram
Sriram

Reputation: 9514

Inline attachments are done using content-id. Docs source

$image_data = file_get_contents($SMap);
// Notice that $image_data is the raw file data of the attachment.

$ImageCode = "<img style=\"padding:0 50px 0 0;\" src=\"cid:img1\" alt=\"Image\" />";
$message = new Message();
$message->setSender("[email protected]");
$message->addTo("[email protected]");
$message->setSubject("Example email");
$message->setHtmlBody($ImageCode);
$message->addAttachment('image.jpg', $image_data, "img1");
$message->send();

Upvotes: 1

Related Questions