Configuring a mail driver in Laravel (using MAMP)

时间:2018-09-18 20:36:15

标签: php laravel email

I'm trying to use Laravel's auth package, and I'm getting various errors when trying to use its "send password reset link" option. I'm using MAMP as the server. My .env by default looks like this:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

I keep getting Swift_TransportException errors when I try to send mail.

Am I supposed to connect a Gmail address I own, using my email and password, essentially telling Laravel to use Gmail as the mail server? Isn't this a security risk since my password would be out in the open?

As an alternative, can/should I add a mail server to MAMP and use its credentials? Again, isn't that a security risk?

1 个答案:

答案 0 :(得分:0)

  1. 此配置会将电子邮件保存到日志文件:

    MAIL_DRIVER=log
    MAIL_HOST=mailtrap.io
    MAIL_PORT=587
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=tls
    
  2. 如果您在Sendgrid中注册,则可以使用他们的smtp服务器。 此配置将Sendgrid用作smtp服务器:

     MAIL_DRIVER=smtp
     MAIL_HOST=smtp.sendgrid.net
     MAIL_PORT=587
     MAIL_USERNAME=your_user_name_from_sendgrid
     MAIL_PASSWORD=your_password_from_password
     MAIL_ENCRYPTION=tls