【问题标题】:How to get Access Token from gmail?如何从 gmail 获取访问令牌?
【发布时间】:2019-06-24 18:07:27
【问题描述】:

我在这里面临的主要问题是,当我点击 sendmail api(此 API 使用 google email api 发送邮件)时,它给了我Undefined index: access_token 的错误

我想在我的 Laravel 项目中使用 GMAIL 电子邮件 API 发送电子邮件。为此,我关注了这个 github 文档:https://github.com/dacastro4/laravel-gmail。我能够成功地用我的项目进行设置。但随后出现上述错误。以下是我的代码:

        use Dacastro4\LaravelGmail\Services\Message\Mail;

        $mail = new Mail;
        $mail->to( 'TOMAIL', $name = "Tester" );
        $mail->from( 'MYMAIL', $name = "Own Tester" );
        $mail->subject( "Hello World" );
        $mail->message( "Google It Brother." );
        $mail->send();

预期的响应是它应该使用 gmail api 将电子邮件发送给用户。

【问题讨论】:

  • 发送邮件与 Gmail api 不同。如果你想使用developers.google.com/gmail/api/quickstart/php,你应该查看 gmail api 的 PHP 快速入门如果你想通过 smtp 服务器,那么你必须为用户发送登录名和密码artisansweb.net/sending-email-via-gmail-smtp-server-laravel
  • 我在核心 php 中完成了这个 quickstart.php 的东西,但我无法为 laravel 设置执行此操作。这就是我使用该软件包的原因,但这给了我 access_token @DaImTo 的问题
  • 您不需要 SMTP 服务器的访问令牌。您需要发送登录名和密码这两个不同的东西。如果你想使用 gmail api,你将不得不为 gmail api 找到一个 larvel 说唱歌手。 github.com/dacastro4/laravel-gmail

标签: laravel-5 gmail-api google-client


【解决方案1】:

试试下面的链接:

https://artisansweb.net/sending-email-via-gmail-smtp-server-laravel/

小结:

在您的 Gmail 帐户设置中:

1. Allow Less Secure App Access
2. Create an app password
3. in your application configuration, provide the your gmail account's app password (not your gmail account password)

【讨论】:

  • 谢谢,但我需要使用 gmail api 而不是这种 SMTP 方式。
  • 本教程是关于 Gmail 的 SMTP 的。
猜你喜欢
  • 2016-07-12
  • 2016-08-28
  • 2012-09-16
  • 2013-03-30
  • 2021-11-10
  • 2023-03-07
  • 2012-04-09
  • 1970-01-01
  • 2019-09-09
相关资源
最近更新 更多