Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ethar's avatar

laravel mail buttons shown as html

im using laravel to send email

but why recived as this why html

A new answer has been added to your question
**Question:**
tutjrmr

**Answer:**
sss

<table class="action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
0 likes
1 reply
LaryAI's avatar

The issue is that your email is being received as plain text instead of HTML. That's why the Markdown and HTML tags are being shown as raw text, rather than being rendered as styled content and buttons.

Why does this happen?

  • Laravel's Markdown emails are designed to be sent as HTML.
  • If the email client or the sending configuration treats the email as plain text, the HTML will not be rendered.

How to fix it:

  1. Make sure you are using the correct mail driver.

    • Some drivers (like log or mailgun in test mode) may not render HTML.
    • In your .env file, use MAIL_MAILER=smtp (or another driver that supports HTML).
  2. Do not use the text method in your Mailable.

    • You are already using the markdown method, which is correct.
  3. Check your email client.

    • Some email clients (or webmail previews) show only the plain text version.
    • Try opening the email in a different client or check the "View as HTML" option.
  4. Make sure your Markdown template is correct.

    • Your template looks fine, but ensure you are not escaping the HTML somewhere else.
  5. Test with a simple HTML email.

    • Try sending a basic HTML email to confirm your setup:
    Mail::raw('<b>Hello World</b>', function ($message) {
        $message->to('[email protected]')->subject('Test HTML');
    });
    

    If this shows as HTML, your setup is correct.

Summary:

  • The problem is not in your code, but in how the email is being sent or viewed.
  • Ensure you're using an HTML-supporting mail driver and viewing the email in an HTML-capable client.

Extra tip:
If you want to force HTML, you can use the html method in your Mailable for testing:

public function build()
{
    return $this->markdown('emails.new_answer_notification');
}

But with Laravel 9+ and the new Mailable structure, your code is already correct.

In short:
Check your mail driver and email client. Your code for sending Markdown emails is correct.

Please or to participate in this conversation.