s-ichikawa / laravel-sendgrid-driver

This library can add sendgrid driver into the laravel's mail configure.
MIT License
391 stars 92 forks source link

Laravel 5.4.23 - Mailable Categories not In Sendgrid #60

Closed Elidrake closed 7 years ago

Elidrake commented 7 years ago
    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.password')
        ->subject('Password Reset Request')
        ->sendgrid([
            'categories'=>['passwordReset']
        ]);
    }

I am using the guide in the readme for attaching the Sendgrid trait, but I'm finding that the above code does not actually attach the category for viewing in Sendgrid - as in, after sending off one of these emails, it doesn't actually have the category attached to it in the Sendgrid interface.

I am using the V3 API.

Elidrake commented 7 years ago

I believe I see the issue, actually. It appears this line here is no longer valid: if ($this instanceof Mailable && env('MAIL_DRIVER') == "sendgrid") { Per the 5.3 upgrade guide, under Configuration - Caching and ENV, if you cache the configuration (as most do on production), you cannot access env values using env. Instead, they are attached to the container, and can be accessed in this case via config('mail.driver').

Elidrake commented 7 years ago

I've put up a PR that makes it all work whether or not you cache the config.

https://github.com/s-ichikawa/laravel-sendgrid-driver/pull/61

s-ichikawa commented 7 years ago

Thanks !