Laravel 8 Swiftmailer 标头无效

问题描述 投票:0回答:0

我正在使用 Laravel 8 Swiftmailer 发送这封邮件

    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");
    });

它适用于谷歌和雅虎的收件人。 但是,我在发送给这个收件人时收到错误消息。 (到目前为止检测到一个)。 它给了我这个错误。

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

我检查了电子邮件标题,发现 addTextHeader() 方法生成的标题在冒号前有一个空格。

X-ElasticEmail-Channel : Testing

默认的标题格式是这样的。没有空间。

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

这与空间有关吗?为什么只有某些电子邮件提供商可以接受这个?

laravel swiftmailer
© www.soinside.com 2019 - 2024. All rights reserved.