Some email modification and customization tips in WordPress _ PHP-php Tutorial

Source: Internet
Author: User
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 ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.