最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Send email with Content-Type textplain

programmeradmin8浏览0评论

I have problem with emails in Wordpress. I have to send message with Content-Type is text/plain, but in Wordpress default Content-Type is text/html. That change chars like & to &.

How can I change Content-Type? Please help.

I have problem with emails in Wordpress. I have to send message with Content-Type is text/plain, but in Wordpress default Content-Type is text/html. That change chars like & to &.

How can I change Content-Type? Please help.

Share Improve this question edited Jul 28, 2020 at 18:22 mozboz 2,6281 gold badge12 silver badges23 bronze badges asked Jul 28, 2020 at 18:08 Hubert RębiałkowskiHubert Rębiałkowski 32 bronze badges 5
  • What did you find when you searched for how to do this? It seems as though a search for example 'wordpress change content-type of email' returns lots of results. If you add the code you have so far to the question it can help people in providing an answer. – mozboz Commented Jul 28, 2020 at 18:12
  • search for example 'wordpress change content-type of email' returns from plain to html, that not resolve my problem. I don't have code. I use Notifications plugin. – Hubert Rębiałkowski Commented Jul 28, 2020 at 18:17
  • Ah, it depends how that plugin works then. You could try to ask the authors of that plugin for help. If you know how to do it you could try adding the code from my answer to your functions.php, it may do what you want. – mozboz Commented Jul 28, 2020 at 18:53
  • Your code only set header to text/plain, but message is in html. Thanks. – Hubert Rębiałkowski Commented Jul 28, 2020 at 19:02
  • Then you need to change the message content to plain text... ;-) That happens by whatever writes the message, no automatic conversion can happen. – mozboz Commented Jul 28, 2020 at 19:07
Add a comment  | 

1 Answer 1

Reset to default 0

You didn't say how you're sending emails, but if you're using wp_mail, this is how you change the type to text/plain:

function wp_set_mail_plaintext() {
    return 'text/plain';
}
add_filter( 'wp_mail_content_type', 'wp_set_mail_plaintext' );
发布评论

评论列表(0)

  1. 暂无评论