Laravel 5 Mail - Gmail - AbstractSmtpTransport.php第399行:未初始化的字符串偏移量:3 [英] Laravel 5 Mail - Gmail - AbstractSmtpTransport.php line 399:Uninitialized string offset: 3

查看:253
本文介绍了Laravel 5 Mail - Gmail - AbstractSmtpTransport.php第399行:未初始化的字符串偏移量:3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我很难得到我的邮件相当困难的时间,我没有找到一个类似的解决方案。我试图使用SMTP从我的网站通过Gmail发送基本电子邮件。一切似乎都正确。感谢您的帮助



•我的帐户是xxx@gmail.com。我已经为此帐户设置了两步验证。 xxx@gmail.com帐户的密码为a123

•我正尝试从我的电子邮件marketing@y.com发送它。 for xxx@gmail.com
•在gmail-settings-account和import下发送邮件为
•我有

o Marketing - 不是别名。

o邮件通过以下方式发送:smtp.gmail.com

o使用TLS
在端口587 $ b $上进行安全连接•单击编辑信息 - 名称:

o Marketing
o电子邮件地址:marketing@y.com
•单击下一步 - 编辑电子邮件地址 - 通过SMTP服务器发送邮件
o配置您的邮件通过SamsSocial.com SMTP服务器发送了解更多信息
o您目前正在使用:使用TLS
o的端口587上的安全连接要进行编辑,请在下面调整您的偏好设置。
o SMTP服务器:smtp.gmail.com $ b $端口:用户名:xxx@gmail.com
o密码:OTHERPASS
o使用TLS进行安全连接(推荐)



我得到以下错误,并且它花费了很长时间

ErrorException在AbstractSmtpTransport.php行399:
未初始化字符串偏移量: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'=>' 334VXNlcm5hbWU6 )在AbstractSmtpTransport.php中的第399行
在AbstractSmtpTransport.php中的getFullResponse('8')第277行
在Swift_Transport_AbstractSmtpTransport-> executeCommand(' AUTH LOGIN',数组(在LoginAuthenticator.php第40行中的Swift_Transport_EsmtpTransport-> executeCommand('AUTH LOGIN',数组('334'))
在EsmtpTransport.php中的第270行b
$ b

controller

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

Mail :: send('admin.marketing.emails.test',['user'=> $ user],function($ m)use($ user){
/ /我已经有了和没有从
$ m->到('test@yahoo.com','peter') - >主题('这是我们怎么做');
});
返回重定向('admin / marketing');

}

Test.blade.php

 您好{{$ user ['name']}}。这是我们发送的第一封电子邮件

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'=> '营销'],
'加密'=> 'tls',
'username'=> env('MAIL_USERNAME',xxx @ gmail.com'),
'password'=> env('MAIL_PASSWORD','OTHERPASS'),
'sendmail'=> '/ usr / sbin / sendmail -bs',
'pretend'=>假,

];

.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=>数组:2 [▼
address=> Marketing@y.com
name=> 营销
]
加密=> tls
username=> xxx@gmail.com
password=> OTHERPASS
sendmail=> / usr / sbin / sendmail -bs
假装=> false
]


解决方案

错误可能是误导,但它实际上是因为对gmail smtp服务器的认证产生了意想不到的输出。 Google改变了授权对客户端应用程序的工作方式。

现在,您需要为代表您访问邮件或日历的应用检索应用密码,然后使用该应用密码您用于网络的通常密码。
此处更多信息: https://support.google.com/ accounts / answer / 185833?hl = zh_CN


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
]

解决方案

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

这篇关于Laravel 5 Mail - Gmail - AbstractSmtpTransport.php第399行:未初始化的字符串偏移量:3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆