简体   繁体   中英

Why does Laravel replace a tab by a “=09” string when sending mails?

I'm using the following code to send mails in Laravel:

\Mail::send('emails.mailing', $data,
    function ($message) use ($user) {
        $message
          ->to($user->email, $user->first_name)
          ->subject('some nice subject');
});

The emails/mailing.blade.php file contains the html with a lot of tabs to make the syntax nicer for coding, however when I look at the source of the recieved email, all tabs are replaced by a "=09" string.

What is causing this, and how can I fix this?

edit: One imo good solution would be to remove all tabs before sending the mail. How would I do this?

=09 is the quoted-printable encoding for a tab character (see RFC 1521 .) On his blog , Zach Alam suggests telling it to use the 8-bit encoder instead of the default (QP) one:

$message->setEncoder(Swift_Encoding::get8BitEncoding());

In the context of your code, this could likely be done via:

\Mail::send('emails.mailing', $data,
    function ($message) use ($user) {
        $message
          ->setEncoder(Swift_Encoding::get8BitEncoding())
          ->to($user->email, $user->first_name)
          ->subject('some nice subject');
});

对于您的修改问题,您可以在发送邮件之前,从邮件中删除所有标签:

$message_in_your_emails_mailing_view = str_replace(chr(9), '', $message_in_your_emails_mailing_view);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM