Some of the changes in WordPress email and custom Tips _php tips

Source: Internet
Author: User
Tags wordpress email

Change the message content type to HTML
sending mail in WordPress requires the use of the Wp_mail () function, 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 the message, in addition to sending "content-type:text/" headers information, you can also use the filter to unify the changes.

/**
  *wordpress Change 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 be custom 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.

customizing mail and senders for messages
When you use the SMTP plug-in, you can customize the sender and mail of the message, and here's the question, how do you customize the sender and the mailbox of the message without using the SMTP plug-in?

By default, the sender is "WordPress < wordpress@example.com >" so that users cannot reply directly, and can easily be judged as spam, causing users to receive them.

If you want to modify the sender and the sender's mailbox, just use a small piece of code and put it in the functions.php (Learn more):

/**
  *wordpress custom mail to send mail and sender
  *http://www.endskin.com/change-mail-from-info/*/
/Send person
function Bing_wp_mail_from_name () {return
  ' bin fruit ';//Can be modified
by itself}
add_filter (' wp_mail_from_name ', ' bing_wp_ Mail_from_name ');
 
Send mail
function Bing_wp_mail_from () {return
  ' admin@endskin.com ';//Can be modified by itself
}
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.