【问题标题】:Laravel 5 Mail - Gmail - AbstractSmtpTransport.php line 399:Uninitialized string offset: 3Laravel 5 邮件 - Gmail - AbstractSmtpTransport.php 第 399 行:未初始化的字符串偏移量:3
【发布时间】:2017-05-02 14:06:19
【问题描述】:

所以我很难收到我的邮件,而且我没有找到类似的解决方案。我正在尝试使用 SMTP 从我的网站通过 gmail 发送基本电子邮件。一切似乎都是正确的。感谢您的帮助

• 我的帐户是 xxx@gmail.com。我已在此帐户上设置了两步验证。 xxx@gmail.com 帐户的密码为 a123
• 我正在尝试从我的电子邮件marketing@y.com 发送它。对于 xxx@gmail.com • 在 gmail-settings-account 和 import- 发送邮件为 • 我有
o 营销 - 不是别名。
o 邮件通过以下方式发送:smtp.gmail.com
o 端口 587 上的安全连接 o 使用 TLS • 单击编辑信息 - 名称:
o 营销 o 电子邮件地址:marketing@y.com • 单击下一步 - 编辑电子邮件地址 - 通过您的 SMTP 服务器发送邮件 o 将您的邮件配置为通过 SamsSocial.com SMTP 服务器发送 了解更多 o 您当前正在使用:使用 TLS 的端口 587 上的安全连接 o 要进行编辑,请在下方调整您的偏好。 o SMTP 服务器:smtp.gmail.com o 端口:用户名:xxx@gmail.com o 密码:OTHERPASS o 使用 TLS 的安全连接(推荐)

我收到以下错误,并且需要很长时间

AbstractSmtpTransport.php 第 399 行中的 ErrorException: 未初始化的字符串偏移量:3 在 AbstractSmtpTransport.php 第 399 行 在 HandleExceptions->handleError('8', '未初始化的字符串偏移量: 3', 'C:\wamp\www\d\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php', '399' , array('seq' => '8', 'response' => '�334 VXNlcm5hbWU6 L', 'line' => 'L')) 在 AbstractSmtpTransport.php 第 399 行 在 AbstractSmtpTransport.php 第 277 行中的 Swift_Transport_AbstractSmtpTransport->_getFullResponse('8') 在 EsmtpTransport.php 第 270 行中的 Swift_Transport_AbstractSmtpTransport->executeCommand('AUTH LOGIN', array('334'), array()) 在 LoginAuthenticator.php 第 40 行中的 Swift_Transport_EsmtpTransport->executeCommand('AUTH LOGIN', array('334'))

控制器

public function sendEmailReminder()
    {
        $user = User::findOrFail(1);
        // dd(Config::get("mail"));

        Mail::send('admin.marketing.emails.test', ['user' => $user], function ($m) use ($user) {
           //i've had this with and without the from
            $m->to('test@yahoo.com', 'peter')->subject('This is how we do it');
        });
        return redirect('admin/marketing');

    }

Test.blade.php

Hi {{$user['name']}}. this is the first email we've sent

配置/mail.php

<?php

return [
    'driver' =>  'smtp',
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => 'Marketing@t.com', 'name' => 'Marketing'],
    'encryption' => 'tls',
    'username' => env('MAIL_USERNAME',xxx@gmail.com'),
    'password' => env('MAIL_PASSWORD','OTHERPASS’),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,

];

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxx@gmail.com
MAIL_PASSWORD=OTHERPASS
MAIL_ENCRYPTION=tls

当我做 dd(Config::get("mail")); - 我得到以下看起来正确的内容

array:9 [▼
  "driver" => "smtp"
  "host" => "smtp.gmail.com"
  "port" => "587"
  "from" => array:2 [▼
    "address" => "Marketing@y.com"
    "name" => "Marketing"
  ]
  "encryption" => "tls"
  "username" => "xxx@gmail.com"
  "password" => "OTHERPASS"
  "sendmail" => "/usr/sbin/sendmail -bs"
  "pretend" => false
]

【问题讨论】:

    标签: laravel email gmail


    【解决方案1】:

    该错误可能具有误导性,但实际上是因为针对 gmail smtp 服务器的身份验证产生了意外的输出。 Google 改变了客户端应用程序授权的工作方式。

    现在有必要为代表您访问邮件或日历的应用程序检索应用程序密码,并使用该应用程序密码而不是您用于网络的常用密码。 更多信息在这里:https://support.google.com/accounts/answer/185833?hl=en

    【讨论】:

    • 好吧 - 回头看 - 这实际上是 OTHERPASS。我已经完成了,OTHERPASS 是 16 个字符。这 16 个字符是否需要在每 4 个字符之后用空格分隔?
    • 一起。它有一个“复制按钮”,可以完全复制它应该去的地方
    • 所以应用密码似乎不是它,因为它已经连接,因为填充了应用密码的最后使用日期,所以不是它。除非我在此处输入的位置有问题,否则可能会出现问题,但这是我得到的错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-11
    • 2017-05-10
    • 1970-01-01
    • 1970-01-01
    • 2016-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多