web-dev-qa-db-fra.com

Laravel SwiftMailer: Le code de réponse attendu 250 mais le code "530", avec le message "530-5.5.1 Authentification requise

J'utilise Laravel 5.2, et Swift Mailer pour la réinitialisation du mot de passe . J'ai une vérification en deux étapes sur mon compte Gmail. .

Comme le dit l'aide de Google:


Si vous avez activé la vérification en deux étapes pour votre compte, vous devrez peut-être entrer un mot de passe d'application au lieu de votre mot de passe habituel.


J'ai les paramètres suivants sur mail.php:

return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'Host' => env('MAIL_Host', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 465),
    'from' => ['address' => '[email protected]', 'name' => 'Shafee'],
    'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
    'username' => env('[email protected]'),
    'password' => env('MY_Gmail_API_KEY'),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => env('MAIL_PRETEND', false),

];

Sur le .env j'ai:

MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=MY_Gmail_API_KEY
MAIL_ENCRYPTION=ssl

L'erreur suivante apparaît:

Swift_TransportException in AbstractSmtpTransport.php line 383:

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. 

Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 w10sm15831823wjk.18 - gsmtp
"
5
Gammer

Essayez d'activer les "applications moins sécurisées" de votre compte sur cette page . Lire cette réponse google .

2
Rifki

Utilisez tls au lieu de ssl et utilisez le port 587.

Utilisez la clé ou paasword.

Ou s'il vous plaît lancer php artisan config: cache

Ou essayez d'activer les "applications moins sécurisées" de votre compte sur cette page. 

4
Laravel User

Suivez ce fichier ......

Change "Username" => env ('[email protected] ') en "Username" =>' [email protected] ';

Identique au mot de passe ...

revenir [

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill",
|            "ses", "sparkpost", "log"
|
*/

'driver' => env('MAIL_DRIVER', 'smtp'),

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the Host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'Host' => env('MAIL_Host', 'smtp.gmail.com'),

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the Host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => env('MAIL_PORT', 587),

/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/

'from' => ['address' => '[email protected]', 'name' => 'shashikant parmar111'],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

**'username' => '[email protected]',**

/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/

**'password' => '********',**

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,

];

2
shashikant parmar

Dans laravel, j'avais également le même problème mais c'est à cause de ... Je n'utilisais pas "use clause" dans la fonction Mail.

L'erreur a été résolue après l'utilisation de "use clause".

1
Rashmi Jain

Vous pouvez essayer les étapes suivantes 

  1. Activez les «applications moins sécurisées» pour votre compte ici
  2. Essayez en définissant votre chiffrement de courrier sur tls et votre port sur 587 dans votre fichier .env
    MAIL_Host = smtp.gmail.com 
    MAIL_PORT = 587 
    [email protected] 
    MAIL_PASSWORD = votre-mot de passe 
    MAIL_ENCRYPTION = tls 
  3. Puis lancez Php artisan cache: clear

Cela a bien fonctionné pour moi.

0
Joynal Abedin