What are the skills of mail modification and customization in WordPress
This article is about email modification and customization techniques in WordPress. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Change the message content type to HTML
You need to use the wp_mail () function to send a message in WordPress, but the default type of message content is "text/plain", which means HTML is not supported.
If you want to add HTML code to the content of your email, you can modify it uniformly using the filter in addition to sending the headers message "Content-Type: text/".
/ * WordPress changes the message content type to HTML * http://www.endskin.com/mail-content-type-html/*/function Bing_set_html_content_type_html () {return 'text/html';// can customize the type} add_filter (' wp_mail_content_type', 'Bing_set_html_content_type_html')
In this way, the contents of the mailbox support HTML code by default.
Customize the sending message and sender of the message
When using the SMTP plug-in, you can customize the sender and mail of the email, so there is a question: how can you customize the sender and mailbox of the email without using the SMTP plug-in?
By default, the sender is "WordPress"
< wordpress@example.com >In this way, users can not reply directly, and it is easy to be judged as spam, resulting in users can not receive.
If you want to modify the sender and sender mailbox, you only need to use a small piece of code and put it in functions.php (learn more):
/ * WordPress Custom Mail delivery and Sender * http://www.endskin.com/change-mail-from-info/*/// Sender function Bing_wp_mail_from_name () {return 'Binguo'; / / you can modify} add_filter ('wp_mail_from_name',' Bing_wp_mail_from_name'); / / send email function Bing_wp_mail_from () {return 'admin@endskin.com' / / you can modify} add_filter ('wp_mail_from',' Bing_wp_mail_from'); thank you for reading! This is the end of this article on "what are the skills of email modification and customization in WordPress?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!