简体   繁体   中英

Issues while sending emails using Laravel…

When sending the email, it is not formatting it correctly, it is displaying it in plain text and not using the HTML my view has in it.

The way I send it:

Mail::to($request->user()->mail)->send(new AccountLocked(Auth::user()));

AccountLocked.php:

class AccountLocked extends Mailable
{
    use Queueable, SerializesModels;

    public $user;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.user.account_locked');
    }
}

This isn't an issue with Laravel, if you actually view the data being sent in the request you'll see Laravel will format the email properly, with a valid HTML code.

This issue is probably the targets email provider blocking the HTML, I know a few email providers that do this, you may want to check that before thinking its Laravel.

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