Support » Fixing WordPress » WP_Mail is not sending email (HTML)

  • I have an email issue in WordPress woo-commerce email. it is sending an email using a header plain text email.

    X-Mailer-Type:WPMailSMTP/Admin/Test

    when I try to send an HTML formatted email using the below header it’s not sending. However, both emails are logging in to WP Mail Logging.

    Content-Type: text/html; charset=UTF-8

    I had tried to disable possible security plugins and Spent hours until I found this issue. any WordPress expert developer please help.

    • This topic was modified 1 month, 3 weeks ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Are you certain the HTML version of the email isn’t just going to spam?

    Changing to Content-Type: text/html; charset=UTF-8; won’t prevent the wp_mail() function from doing its job. I use that on several custom themes and plugins I’ve developed, and the mail is always delivered without any drama.

    Another thing to check is that the HTML email itself isn’t ‘spammy’ and getting blocked at the server. It’s not unheard of.

    Alternatively, you could use a 3rd party email transactional service like SMTP2GO or similar. They usually have a free tier.

    Good luck.

    • This reply was modified 1 month, 3 weeks ago by Michael Ott.
    • This reply was modified 1 month, 3 weeks ago by Michael Ott.

    Hello @ks11281986

    Check the below 2 steps:

    HTML template should have an inline stylesheet only. Don’t use any external CSS path.
    By default WordPress, mails are considered as plain text so change it to HTML type using headers parameter or using a hook.

    Check this URL: https://developer.wordpress.org/reference/functions/wp_mail/

    Check content: The default content type is ‘text/plain’ which does not allow using HTML. You can set the content type of the email either by using the ‘wp_mail_content_type‘ filter ( see example below) or by including a header like “Content-type: text/html”. Be careful to reset ‘wp_mail_content_type’ back to ‘text/plain’ after you send your message, though, because failing to do so could lead to unexpected problems with e-mails from WP or plugins/themes.

    Reference URL to set it by hook: (Check the example at below URL)
    https://developer.wordpress.org/reference/hooks/wp_mail_content_type/

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.