【发布时间】: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
]
【问题讨论】: