s-ichikawa / laravel-sendgrid-driver

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

SendGrid Categories: base64_encode() expects parameter 1 to be string, array given #88

Closed danhorton7 closed 5 years ago

danhorton7 commented 5 years ago
public function build()
    {
        return $this
            ->view('mail.notifications.userassigned')
            ->subject('New task assigned')
            ->sendgrid([
                'categories' => [
                    env('SENDGRID_CATEGORY')
                ],
            ]);
    }

C:\inetpub\wwwroot\laravel\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Encoder\Base64Encoder.php

 /**
     * Takes an unencoded string and produces a Base64 encoded string from it.
     *
     * Base64 encoded strings have a maximum line length of 76 characters.
     * If the first line needs to be shorter, indicate the difference with
     * $firstLineOffset.
     *
     * @param string $string          to encode
     * @param int    $firstLineOffset
     * @param int    $maxLineLength   optional, 0 indicates the default of 76 bytes
     *
     * @return string
     */
    public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
    {
        if (0 >= $maxLineLength || 76 < $maxLineLength) {
            $maxLineLength = 76;
        }

        $encodedString = base64_encode($string);
        $firstLine = '';

        if (0 != $firstLineOffset) {
            $firstLine = substr(
                $encodedString, 0, $maxLineLength - $firstLineOffset
                )."\r\n";
            $encodedString = substr(
                $encodedString, $maxLineLength - $firstLineOffset
                );
        }

        return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n"));
    }

    /**
     * Does nothing.
     */
    public function charsetChanged($charset)
    {
    }

Arguments array:1 [▼ "categories" => array:1 [▼ 0 => "xxxxxx" ] ]`

s-ichikawa commented 5 years ago

Can you send email without categories? If it was success, I want to know SENDGRID_CATEGORY env value format. And if you can, need more info (e.g. laravel's version or stack trace)

danhorton7 commented 5 years ago

Hi Shingo

laravel/framework v5.7.27 s-ichikawa/laravel-sendgrid-driver 2.0.4 swiftmailer/swiftmailer v6.1.3

SENDGRID_CATEGORY='ejOkOxxxxxxxxxxxxx'

This happens both with quotes and without

screencapture-xgbd016310-telescope-exceptions-8d0a9f21-cd0b-460d-bcf1-c6075a95bd39-2019-02-21-20_46_15

s-ichikawa commented 5 years ago

I could send email by same version. as like below. https://github.com/s-ichikawa/laravel57/blob/master/app/Mail/ApiSimpleMailable.php#L32

but after installed telescope, happen same error. I will investigate this problem but now little busy. If you are no problem, try without telescope or inactivate.

helmerdavila commented 5 years ago

Same issue. Any fix?

s-ichikawa commented 5 years ago

Yes, fixed in v2.0.5! And if you have sending email by mailer->send(), please read this. https://github.com/s-ichikawa/laravel-sendgrid-driver#using-with-telescope