: This article mainly introduces some email modification and customization skills in WordPress. For more information about PHP tutorials, see. Change email content type to HTML
In WordPress
Send emailThe wp_mail () function is required, but the default mail content type is "text/plain", that is, HTML is not supported.
If you want to add HTML code to the Mail Content, in addition to sending headers information of "Content-Type: text/", you can also use the filter to modify it in a unified manner.
/*** WordPress: change the Mail content type to HTML * javasbing_set_html_content_type_html () {return 'text/html'; // custom type} add_filter ('WP _ mail_content_type ', 'bing _ set_html_content_type_html ');
In this way, the content of the mailbox supports HTML code by default.
Custom emailSend emailAnd sender
When using the SMTP plug-in, you can customize the sender and email of the mail. here is a problem. if the SMTP plug-in is not used, how can I customize the sender and sender email of the mail?
By default, the sender is WordPress <wordpress@example.com>, so that the user cannot reply directly and is easily identified as spam, causing the user to fail to receive it.
To modify the sender and sender's email address, you only need to use a small code and put it in functions. php (learn more:
/*** WordPress custom emailSend emailAnd sender * export Bing_wp_mail_from_name () {return 'bingo'; // you can modify it by yourself} add_filter ('WP _ mail_from_name ', 'Bing _ wp_mail_from_name ');//Send emailFunction Bing_wp_mail_from () {return 'admin @ endskin.com '; // you can modify it by yourself} add_filter ('WP _ mail_from', 'Bing _ wp_mail_from ');
The above introduces some modification and customization skills for WordPress emails, including the content for sending emails, and hope to help those who are interested in PHP tutorials.