Назад | Перейти на главную страницу

Laravel 5.5 Send Mail с драйвером Sendmail CentOS - (исходящее) соединение истекло

Я пытаюсь отправлять электронные письма с помощью драйвера sendmail, но он не работает, и у меня нет ошибок.

Мой .env файл:

MAIL_DRIVER=sendmail
MAIL_HOST=
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Мой mail.php файл:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | 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", "sendmail", "mailgun", "mandrill", "ses",
    |            "sparkpost", "log", "array"
    |
    */

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

    /*
    |--------------------------------------------------------------------------
    | 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 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' => env('MAIL_FROM_ADDRESS', 'no-reply@inspvirtual.mx'),
        'name' => env('MAIL_FROM_NAME', 'INSP Virtual'),
    ],

    /*
    |--------------------------------------------------------------------------
    | 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' => env('MAIL_USERNAME', null),

    'password' => env('MAIL_PASSWORD', null),

    /*
    |--------------------------------------------------------------------------
    | 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',

    /*
    |--------------------------------------------------------------------------
    | Markdown Mail Settings
    |--------------------------------------------------------------------------
    |
    | If you are using Markdown based email rendering, you may configure your
    | theme and component paths here, allowing you to customize the design
    | of the emails. Or, you may simply stick with the Laravel defaults!
    |
    */

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

Поскольку у меня нет ошибок, даже в файле laravel.log я не знаю даже, с чего начать проверку, я проверил правильный путь sendmail, и он был правильным, что мне не хватает?

Я также читал, что вам нужно изменить некоторые вещи в / etc / hosts. Я немного изменил его, добавив "inspvirtual.mx", но я не совсем уверен, правильно ли это:

127.0.0.1   inspvirtual.mx
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Журнал почты распечатывает это после того, как я пытаюсь отправить электронное письмо:

May 26 14:12:35 inspvirtual sendmail[3130]: x4Q9BDjB010067: to=<aaron@juicyboom.com>, delay=09:01:22, xdelay=00:00:00, mailer=esmtp, pri=1020554, relay=mail.juicyboom.com., dsn=4.0.0, stat=Deferred: Connection timed out with mail.juicyboom.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q9BWIJ010111: to=<aaron@juicyboom.com>, delay=09:01:03, xdelay=00:00:00, mailer=esmtp, pri=1020554, relay=mail.juicyboom.com., dsn=4.0.0, stat=Deferred: Connection timed out with mail.juicyboom.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q9CdaV010235: to=<aaron@juicyboom.com>, delay=08:59:56, xdelay=00:00:00, mailer=esmtp, pri=1020554, relay=mail.juicyboom.com., dsn=4.0.0, stat=Deferred: Connection timed out with mail.juicyboom.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q9Nnob011458: to=<aaron@juicyboom.com>, delay=08:48:46, xdelay=00:00:00, mailer=esmtp, pri=1020554, relay=mail.juicyboom.com., dsn=4.0.0, stat=Deferred: Connection timed out with mail.juicyboom.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q8pH0A007887: to=<aaron.070194@gmail.com>, delay=09:21:18, xdelay=00:00:00, mailer=esmtp, pri=1020560, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q8rkK3008160: to=<aaron.070194@gmail.com>, delay=09:18:49, xdelay=00:00:00, mailer=esmtp, pri=1020560, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q8TUXJ005341: to=<aaron.070194@gmail.com>, delay=09:43:05, xdelay=00:00:00, mailer=esmtp, pri=1110560, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q8Wnpn005708: to=<aaron.070194@gmail.com>, delay=09:39:46, xdelay=00:00:00, mailer=esmtp, pri=1110560, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q8bZaD006249: to=<aaron.070194@gmail.com>, delay=09:35:00, xdelay=00:00:00, mailer=esmtp, pri=1110560, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 26 14:12:35 inspvirtual sendmail[3130]: x4Q8fPQg006712: to=<aaron.070194@gmail.com>, delay=09:31:10, xdelay=00:00:00, mailer=esmtp, pri=1110560, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.

Важно сказать, что я вручную настраиваю все необходимые вещи на этом сервере для работы, поскольку это выделенный сервер, например, DNS.

Я также изменил /etc/mail/sendmail.mc файл в этой строке:

LOCAL_DOMAIN(`inspvirtual.mx')dnl

Я также бегал hostname чтобы проверить правильность имени хоста и распечатать правильное: inspvirtual.mx

Я очень новичок в настройке сервера с 0 вручную, поэтому я немного потерялся здесь ...

Так как Майкл Хэмптон предложил
ЕСЛИ все сообщения остаются в очереди с connection timed out
ЗАТЕМ скорее всего, ваши исходящие SMTP-соединения заблокированы (защищены брандмауэром), например. вашим интернет-провайдером или вашим брандмауэром в интрасети

Предлагаемая процедура проверки:
1. Убедитесь, что вы получаете приветственное сообщение SMTP [Это ошибка sendmail?]
telnet mail.juicyboom.com 25
2. используйте такие инструменты, как tcptraceroute определить местоположение брандмауэра