Laravel 8 Swiftmailer Header is Invalid

42 views Asked by At

I'm using Laravel 8 Swiftmailer to send this email

    Mail::send([], [], function ($message) use ($input) {
        $message->to($input['recp'] , 'Testing')->subject($input['subject'])->getSwiftMessage()->getHeaders()->addTextHeader('X-ElasticEmail-Channel', 'Testing');
        $message->setBody($input['html'], 'text/html');
        $message->from('[email protected]', "Testing");
    });

It works for recipient at google and yahoo. However, I receive an error when sending to this one recipient. (So far one detected). It gave me this error.

Invalid data: Unexpected characters in RFC822 header: b'X-ElasticEmail-Channel : Testing'. - ImprovMX

I checked on the email header and found that the generated header from addTextHeader() method has a space before the colon.

X-ElasticEmail-Channel : Testing

Where the default header format like this. No space.

Subject: User Registration
From: Testing <[email protected]>
To: Email Verification <[email protected]>

Is that something to do with the space and why only certain email provider can accept this?

0

There are 0 answers