This article mainly introduces some email modification and customization skills in WordPress, including modifying emails to HTML format and defining the SMTP mail sender method. For more information, see
Change email content type to HTML
You need to use the wp_mail () function to send emails in WordPress, 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 email sending and 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 email sending and 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 the email function Bing_wp_mail_from () {return 'admin @ endskin.com'; // you can modify it by yourself} add_filter ('WP _ mail_from ', 'bing _ wp_mail_from ');