Change the email content type to HTML
In WordPress Send emailYou need to use the wp_mail() function, but the default type of email content is "text/plain", which means HTML is not supported.
If you want to add HTML code to the email content, in addition to sending the header information of "Content-Type: text/", you can also use filters to modify it uniformly.
/** *WordPress 更改邮件内容类型为 HTML *http://www.endskin.com/mail-content-type-html/ */ function Bing_set_html_content_type_html(){ return 'text/html';//可以自定义类型 } 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.
Customized emailSend emailand sender
When using the SMTP plug-in, you can customize the sender and email of the email. There is a question here. How to customize the sending of the email without using the SMTP plug-in? What about the person and the sending email address?
By default, the sender is "WordPress < wordpress@example.com >", so users cannot reply directly, and it is easily judged as spam, resulting in users not receiving it.
If you want to modify the sender and sender email, you only need to use a small code and put it in functions.php (learn more):
/** *WordPress 自定义邮件<strong>发送邮件</strong>和发件人 *http://www.endskin.com/change-mail-from-info/ */ //发件人 function Bing_wp_mail_from_name(){ return '斌果';//可自行修改 } add_filter( 'wp_mail_from_name', 'Bing_wp_mail_from_name' ); //<strong>发送邮件</strong> function Bing_wp_mail_from(){ return 'admin@endskin.com';//可自行修改 } add_filter( 'wp_mail_from', 'Bing_wp_mail_from' );
The above has introduced some modification and customization techniques for emails in WordPress, including content on sending emails. I hope it will be helpful to friends who are interested in PHP tutorials.