我正在尝试使用此代码在 php 中发送电子邮件,因为它在文档中给出
require_once 'google/appengine/api/mail/Message.php';
use google\appengine\api\mail\Message; //line 6 in my code
// ...
$message_body = "...";
$mail_options = [
"sender" => "admin@example.com",
"to" => "user@example.com",
"subject" => "Your example.com account has been activated.",
"textBody" => $message_body
];
try {
$message = new Message($mail_options);
$message->send();
} catch (InvalidArgumentException $e) {
// ...
}
我收到以下错误
PHP Parse error: syntax error, unexpected 'use' (T_USE) in /base/data/home/apps/s~myapp-home/mail.371603101929416156/save-email.php on line 6
不知何故,appengine 在这条线上抛出了错误
use google\appengine\api\mail\Message;