Laravel 5 Mail - Gmail - AbstractSmtpTransport.php line 399:Uninitialized string offset: 3

。_饼干妹妹 提交于 2019-12-12 04:32:40

问题


so i'm trouble getting a fairly difficult time getting my mail up and i'm not finding a comparable solution out there. I’m trying to send a basic email through gmail from my website using SMTP. Everything seems correct. Thanks for your help

• my account is xxx@gmail.com. i've set up the two step verification on this account. the xxx@gmail.com account has password a123
• i'm trying to send it from my email marketing@y.com. for xxx@gmail.com • under gmail-settings-account and import- send mail as • i have
o Marketing -Not an alias.
o Mail is sent through: smtp.gmail.com
o Secured connection on port 587 o using TLS • clicking on edit info- Name:
o Marketing o Email address: marketing@y.com • Click Next - Edit email address - Send mail through your SMTP server o Configure your mail to be sent through SamsSocial.com SMTP servers Learn more o You are currently using: secured connection on port 587 using TLS o To edit, please adjust your preferences below. o SMTP Server: smtp.gmail.com o Port: Username: xxx@gmail.com o Password: OTHERPASS o Secured connection using TLS (recommended)

i'm getting the following error and it's taking an incredibly long time

ErrorException in AbstractSmtpTransport.php line 399: Uninitialized string offset: 3 in AbstractSmtpTransport.php line 399 at HandleExceptions->handleError('8', 'Uninitialized string offset: 3', 'C:\wamp\www\d\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php', '399', array('seq' => '8', 'response' => '�334 VXNlcm5hbWU6 L', 'line' => 'L')) in AbstractSmtpTransport.php line 399 at Swift_Transport_AbstractSmtpTransport->_getFullResponse('8') in AbstractSmtpTransport.php line 277 at Swift_Transport_AbstractSmtpTransport->executeCommand('AUTH LOGIN ', array('334'), array()) in EsmtpTransport.php line 270 at Swift_Transport_EsmtpTransport->executeCommand('AUTH LOGIN ', array('334')) in LoginAuthenticator.php line 40

controller

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

Config/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

When I do dd(Config::get("mail")); - I get the following which appears correct

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
]

回答1:


The error might be misleading, but it is actually caused because authentication against gmail smtp servers produced an unexpected output. Google has changed the way authorization works for client apps.

Now it is necessary to retrieve an App Password for the app that is accessing Mail or Calendar in your behalf, and use that App Password instead of the usual password that you use for web. More info here: https://support.google.com/accounts/answer/185833?hl=en



来源:https://stackoverflow.com/questions/41190112/laravel-5-mail-gmail-abstractsmtptransport-php-line-399uninitialized-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!