问题
in the official GAE PHP Mail Api doc https://cloud.google.com/appengine/docs/php/mail/ they show this example:
use \google\appengine\api\mail\Message;
// Notice that $image_data is the raw file data of the attachment.
try
{
$message = new Message();
$message->setSender("from@google.com");
$message->addTo("to@google.com");
$message->setSubject("Example email");
$message->setTextBody("Hello, world!");
$message->addAttachment('image.jpg', $image_data, $image_content_id);
$message->send();
} catch (InvalidArgumentException $e) {
// ...
}
but they dont explain how to fill $image_data with an uploaded static file. any help ? if it can be explicit it will be great
thanks diego
回答1:
Use file_get_contents() to retrieve the data you want to send as part of the email.
$image_data = file_get_contents('path/to/static/file.jpg');
Or you can send an image stored in Cloud Storage
$image_data = file_get_contents('gs://my_bucket/path/to/file.jpg');
来源:https://stackoverflow.com/questions/29020871/google-apps-engine-php-mail-api-image-data