Laravel Sendgrid SMTP

Laravel Sendgrid SMTP,laravel,sendgrid,godaddy-api,Laravel,Sendgrid,Godaddy Api,嗨,我正在使用Laravel作为发送电子邮件的后端。 我通过以下指南做到了这一点: 当在我的本地PC上托管项目时,这很好,但是当项目托管在GoDaddy上时,我不断收到500服务器错误。在Sendgrid中,我还执行了发送者身份验证,但仍然收到一个500服务器错误 API路线: Route::get('/mail', 'Auth\v1\AuthController@sendMail'); 控制器功能代码: public function sendMail(){ $data =

嗨,我正在使用Laravel作为发送电子邮件的后端。 我通过以下指南做到了这一点:

当在我的本地PC上托管项目时,这很好,但是当项目托管在GoDaddy上时,我不断收到500服务器错误。在Sendgrid中,我还执行了发送者身份验证,但仍然收到一个500服务器错误

API路线:

Route::get('/mail', 'Auth\v1\AuthController@sendMail');
控制器功能代码:

public function sendMail(){
        $data = ['message' => 'This is a test!'];
        Mail::to('john@example.com')->send(new TestEmail($data));
        return '200 OK';
    }
测试电子邮件类别:

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class TestEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $data;

    public function __construct($data)
    {
        $this->data = $data;
    }

    public function build()
    {
        $address = 'janeexampexample@example.com';
        $subject = 'This is a demo!';
        $name = 'Jane Doe';

        return $this->view('emails.test')
                    ->from($address, $name)
                    ->cc($address, $name)
                    ->bcc($address, $name)
                    ->replyTo($address, $name)
                    ->subject($subject)
                    ->with([ 'message' => $this->data['message'] ]);
    }
}

解决方法是使用Sendgrid API,因为需要在GoDaddy中正确设置SMTP。

您是否按照发布的指南中的说明在.env中设置了正确的变量?Hi@BramVerstraten,是-事实上,当项目在本地托管时,它可以工作。我联系了GoDaddy,问题似乎是由于SMTP请求不允许从其端发出,除非服务器是专用的或专用的。我询问的原因是因为local和production.env通常不同。我猜你是在共享主机上?看起来你应该找一个不同的邮件服务。是的,我们正在使用共享主机现在切换到专用的,希望能让这个工作。。。请问您有什么不同的邮件服务建议?我们使用sparkpost,但不是免费的