在Laravel-5.8中手动创建注册验证,重新发送验证并忘记密码电子邮件

时间:2019-07-24 10:40:19

标签: email sendgrid laravel-5.8

我正在开发一个Web应用程序,其中包括许多功能,例如验证用户,发送电子邮件,发送短信等。在这样做的同时,我在实时服务器中遇到了一个问题,即许多cpanel(例如:godaddy)不支持SMTP中继/第三个派对邮件服务。而且我不想使用内置的邮件服务,这有点慢。因此,我不得不寻找其他选择,我发现Sendgrid具有一个api系统,该系统也可以使用网络api发送邮件。现在,我正在尝试将其与我的应用程序集成。我已经用一般电子邮件测试了Web api,它工作正常。但是不知道我该如何更改laravel的默认邮件系统方法。像->在注册时验证电子邮件,重新发送验证电子邮件,忘记密码等。我不想编写自定义方法,而是想使用laravel使用的方法。

任何人都可以帮助我,如何使用sendgrid Web API覆盖那些邮件功能!

(注意:我使用的是laravel 5.8)

这是我的代码:

    $email = new \SendGrid\Mail\Mail(); 
    $email->setFrom("test@example.com", "Example User");
    $email->setSubject("Sending with SendGrid is Fun");
    $email->addTo("test@gmail.com", "Example User");
    $email->addContent("text/plain", "and easy to do anywhere, even with PHP");
    $email->addContent(
        "text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
    );
    $sendgrid = new \SendGrid(env('SENDGRID_API_KEY'));
    try {
        $response = $sendgrid->send($email);
        print $response->statusCode() . "\n";
        print_r($response->headers());
        print $response->body() . "\n";
    } catch (Exception $e) {
        echo 'Caught exception: '. $e->getMessage() ."\n";
    }

0 个答案:

没有答案
相关问题