0
votes

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 [email protected]. i've set up the two step verification on this account. the [email protected] account has password a123
• i'm trying to send it from my email [email protected]. for [email protected] • 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: [email protected] • 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: [email protected] 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('[email protected]', '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' => '[email protected]', 'name' => 'Marketing'],
    'encryption' => 'tls',
    'username' => env('MAIL_USERNAME',[email protected]'),
    'password' => env('MAIL_PASSWORD','OTHERPASS’),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,

];

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
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" => "[email protected]"
    "name" => "Marketing"
  ]
  "encryption" => "tls"
  "username" => "[email protected]"
  "password" => "OTHERPASS"
  "sendmail" => "/usr/sbin/sendmail -bs"
  "pretend" => false
]
1

1 Answers

0
votes

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