0
您好,我正在嘗試在Google應用引擎中爲我的應用添加一些附件。我發送電子郵件並獲得主題以及主題,但由於某種原因,這些附件沒有通過,並且Google解釋它的方法並沒有真正做到公平。Google App Engine GAE PHP發送附件
這裏是我的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" => "[email protected]",
"to" => "[email protected]",
"cc" => "[email protected]",
"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>
謝謝你,讓我能夠發送附件,但我不能實際上我的郵件提供商查看它們,當我將它們下載預覽說:「文件‘file.png’無法打開,這可能是損壞或使用預覽無法識別的文件格式。 - url:/images/(file.jpg) static_files/images/\ 1 upload:/images/file.jpg 我對應用程序做了一些更改。上面的yaml文件也認爲可以修復它,但無濟於事。我覺得我很接近,但是不能達到目的。我是否還需要添加任何MIME類型的代碼? – user3348167