【发布时间】:2014-03-26 16:51:23
【问题描述】:
您好,我正在尝试在 Google 应用引擎中向我的应用添加一些附件。我发送电子邮件并获取正文和主题,但由于某种原因,附件没有通过,谷歌解释它的方法并没有真正做到公正。
这是我的 app.yaml 文件
application: 'phpmail'
version: 1
runtime:php
api_version:1
threadsafe: true
handlers:
-url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
-url: .*
script:main.php
这里是 main.php 文件
<html>
<head>
other info I have
</head>
<body>
<?php
require_once 'google/appengine/api/mail/Message.php';
use google\appengine\api\mail\Message;
// ...
$message_body = "...";
$mail_options = [
"sender" => "sender@gmail.com",
"to" => "reciever@yahoo.com",
"cc" => "reciever@aol.com",
"subject" => "Your account has been activatedd",
"textBody" => "Guten tag, here is an email, with hopefully two attachments",
];
image= open('./file1.png', 'file2.jpg')
message.attachments=[(file1.png, file2.jpg())]
image.close()
try {
$message = new Message($mail_options);
$message->send();
} catch (InvalidArgumentException $e) {
echo $e;
}
{
echo "Your message has been sent";
}
?>
</body>
</html>
【问题讨论】:
标签: php google-app-engine email yaml email-attachments