How to configure Laravel mail.php to use built-in mail function?

后端 未结 4 1283
花落未央
花落未央 2020-12-13 07:25

I need to send an email via the mail() PHP function. I\'ve read somewhere that I have to change driver parameter in config/mail.php to

4条回答
  •  醉话见心
    2020-12-13 07:52

    To do the same as mail() PHP function does, in most cases you should configure Laravel in the following way:

    Use sendmail, at .env:

    MAIL_DRIVER=sendmail
    

    Host, user, password, port and encryption are not needed.

    At this point, you may check if it already works, but sometimes the next step is also needed.

    Set a new .env option in config/mail.php:

    'sendmail' => env('MAIL_SENDMAIL', '/usr/sbin/sendmail -bs')
    

    Set the sendmail path in .env. You can check sendmail_path at phpinfo(), but it's usually this one:

    MAIL_SENDMAIL='/usr/sbin/sendmail -t -i'
    

提交回复
热议问题