Help us understand the problem. What is going on with this article?

Laravelでmail送信に失敗する場合

More than 3 years have passed since last update.

laravelで下記のようなエラーが発生する場合の参考です。

Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. h8sm146259pfh.49 - gsmtp
"

幾つか英語の解説があります。
http://stackoverflow.com/questions/29100877/trying-to-get-laravel-5-email-to-work

が、自分の場合はうまく行きませんでした。(エラーが変わらない)

で、参考になったのがこちらのページ
https://laravel10.wordpress.com/2015/02/22/%E3%83%A1%E3%83%BC%E3%83%AB%E3%81%AE%E7%92%B0%E5%A2%83%E8%A8%AD%E5%AE%9A/
そのままペタっとでもいけます。

.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=your_address@gmail.com
MAIL_FROM_NAME=your_name
MAIL_USERNAME=your_address@gmail.com
MAIL_PASSWORD=your_password
MAIL_PRETEND=false
.mail.php
<?php

return [
    // Mail Driver
    'driver' => env('MAIL_DRIVER', 'smtp'),

    // SMTP Host Address
    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

    // SMTP Host Port
    'port' => env('MAIL_PORT', 587),

    // Global "From" Address
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', null),
        'name' => env('MAIL_FROM_NAME', null)
    ],

    // E-Mail Encryption Protocol
    'encryption' => env('MAIL_ENCRYPTION', null),

    // SMTP Server Username
    'username' => env('MAIL_USERNAME', null),

    // SMTP Server Password
    'password' => env('MAIL_PASSWORD', null),

    // Sendmail System Path
    'sendmail' => '/usr/sbin/sendmail -bs',

    // Mail "Pretend"
    'pretend' => env('MAIL_PRETEND', false),
];

=========
.envやmail.phpに設定が正しくされていない場合に発生。
変更後キャッシュクリアをしたほうが良い
'php artisan cache:clear'

Artisanコマンドで全ての設定ファイルを一つにまとめることができます。
'php artisan config:cache'

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away