简体   繁体   中英

Can't send SMTP mail with no errors in Laravel 5.8.16

I have a problem with sending mail. After clicking the button "Send," the mail is not sent but has no errors.

.env

MAIL_DRIVER=smtp
MAIL_HOST=mail.ensartkm.com
MAIL_PORT=587
MAIL_USERNAME=xxxxx@xxxxxx.com
MAIL_PASSWORD=xxxxxx
MAIL_ENCRYPTION=false

MAIL_ADMIN=ensar@ensartkm.com

My code to send mail:

$data = $request->all();
$result = Mail::to(env('MAIL_ADMIN'))
    ->send(new ContactFormMail($data['name'],$data['email']));

ContactFormMail is my controller with code below:

class ContactFormMail extends Mailable
{
    use Queueable, SerializesModels;

    protected $name;
    protected $email;

    public function __construct($name, $email)
    {
        $this->name = $name;
        $this->email = $email;
    }

    public function build()
    {
        return $this->markdown('emails.contact-form')
            ->with([
                'name' => $this->name,
                'email' => $this->email,
            ])
            ->subject('New mail');
    }
}

It's possible that there's silent errors or failure messages sent by the server, but not with a failure response code.

I would try sending an email with debug logging for swiftmailer enabled, either by creating a simple test script with swiftmailer, or using a package such as the one below which logs debug information to laravel's log:

https://github.com/oprudkyi/laravel-mail-logger

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM