如何使用带有PHP YII2 Google API客户端的Gmail API发送消息?

时间:2017-05-17 13:23:08

标签: php yii2 gmail-api

如何使用带有PHP YII2 Google API客户端的Gmail API发送消息?

我试图发送电子邮件并且电子邮件已被触发,但同样的电子邮件正在反复发送给我。

  $mail = new PHPMailer();
            $mail->CharSet = "UTF-8";
            $subject = $subject;
            $msg = $message;
            $fromadd = $email;
            $fname = $email;
            $mail->From = $fromadd;
            $mail->FromName = $fname;
            /* $mail->AddAddress($toaddr); */
            foreach ($addr as $ad) {
                $mail->AddAddress(trim($ad));
            }
            foreach ($ccaddr as $add) {
                $mail->AddCC(trim($add));
            }
            $mail->AddReplyTo($fromadd, $fname);
            $mail->Subject = $subject;
            $mail->Body = $msg;
            foreach ($path as $key => $value) {
                $mail->AddAttachment($path[$key], $name[$key]);
            }

            $mail->IsHTML(true);
            $mail->preSend();
            $mime = $mail->getSentMIMEMessage();

1 个答案:

答案 0 :(得分:0)

这不是gmail api,这个php邮件程序如果想要使用它并从你的Gmail发送电子邮件,你必须配置邮件程序并使用与你的Gmail帐户关联的smtp值启动它