Laravel 8 Swiftmailer 标头无效

Laravel 8 Swiftmailer Header is Invalid

提问人:luca ditrimma 提问时间:4/18/2023 更新时间:4/18/2023 访问量:35

问:

我正在使用 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

评论


答: 暂无答案