发送GAE的邮件为PHP

时间:2013-07-26 03:43:05

标签: php google-app-engine

我按照Google指南尝试在GAE GAE guide上发送来自PHP的电子邮件,但我收到了错误消息:

消息收到无效选项:正文

以下是代码:

 require_once 'google/appengine/api/mail/Message.php';

    use google\appengine\api\mail\Message;

    // ...

    $message_body = "...";

    $mail_options = [
        "sender" => "admin@example.com",
        "to" => "user@example.com",
        "subject" => "Your example.com account has been activated.",
        "body" => $message_body
    ];

    try {
        $message = new Message($mail_options);
        $message->send();
        } catch (\InvalidArgumentException $e) {
        // ...
    }

1 个答案:

答案 0 :(得分:2)

我认为您需要指定textBodyhtmlBody,具体取决于您发送的邮件的格式。

$mail_options = [
    "sender" => "admin@example.com",
    "to" => "user@example.com",
    "subject" => "Your example.com account has been activated.",
    "textBody" => $message_body
];