admin管理员组文章数量:1391836
I'm sending emails from Laravel 11 app via SMTP (SendGrid) and viewing them in Gmail.
My HTML email has correct encoding configured:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
However, when I click "Show original" in Gmail and check both text and HTML versions of the email, I see other encodings:
Either "iso-8859-1"
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
...plain text email...
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
...html email...
Or "us-ascii":
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
...plain text email...
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
...html email...
I want everything to be UTF-8 of course.
For the life of me can't find in laravel or sendgrid docs how I can configure the correct encoding. All advice given by LLMs are hallucinations or code from previous laravel versions.
Incorrect encoding creates issues when I use special characters from other languages, like german umlauts.
My email is fairly simple:
$payload = [
'url' => route('login.verify', ['token' => $token]),
];
Mail::to($user->email)->send(new EmailOTP($payload));
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class EmailOTP extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public array $data)
{
}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Your login link',
);
}
public function content(): Content
{
return new Content(
markdown: 'emails.login-link',
with: [
'url' => $this->data['url'],
],
);
}
}
How can I configure emails beint sent to be UTF-8?
本文标签: phpLaravel 11 how to configure email encodingStack Overflow
版权声明:本文标题:php - Laravel 11 how to configure email encoding? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744762491a2623834.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论