谷歌应用引擎PHP邮件API - $ IMAGE_DATA [英] Google Apps Engine PHP Mail API - $image_data
本文介绍了谷歌应用引擎PHP邮件API - $ IMAGE_DATA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在官方GAE PHP邮件API文档 https://cloud.google.com / AppEngine上/文档/ PHP /邮件/ 他们表现出这个例子:
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) {
// ...
}
但他们不解释如何填写$与IMAGE_DATA上传的静态文件。
任何帮助吗?如果能够明确这将是巨大的。
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
谢谢
迭戈
推荐答案
使用的file_get_contents()来检索要发送的电子邮件的一部分数据。
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');
这篇关于谷歌应用引擎PHP邮件API - $ IMAGE_DATA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文