The effects of comments reply to emails are as follows:
Let me first talk about the conventional way to implement this function. This method requires confirmation that your host supports the mail function. Otherwise, it does not work. The following code selects the desired code based on your needs and adds it to the last one in the topic's functions. php file?> Above:
// Modify by stcash. comfunction compute ($ comment_id) {$ admin_email = get_bloginfo ('admin _ email '); $ comment = get_comment ($ comment_id); $ comment_author_email = trim ($ comment-> comment_author_email ); $ parent_id = $ comment-> comment_parent? $ Comment-> comment_parent: ''; $ to = $ parent_id? Trim (get_comment ($ parent_id)-> comment_author_email): ''; $ spam_confirmed = $ comment-> comment_approved; if ($ parent_id! = '') & ($ Spam_confirmed! = 'Spam') & ($! = $ Admin_email) {$ wp_email = 'no-reply @'. preg_replace ('# ^ www \. # ', '', strtolower ($ _ SERVER ['server _ name']); $ subject =' you are in ['. get_option ("blogname "). '] has a new reply'; $ message = ''; $ from =" From :\"". get_option ('blogname '). "\" <$ wp_email> "; $ headers =" $ from \ nContent-Type: text/html; charset = ". get_option ('blog _ charset '). "\ n"; wp_mail ($ to, $ subject, $ message, $ headers) ;}} add_action ('comment _ post', 'comment _ mail_policy ');
It is worth noting that when this function is added at the beginning, an error is reported, which causes the website to return a 500 error and cannot be accessed. It turns out that a file in my topic already contains this function. So it is best to use if (! Function_exists ('comment _ mail_policy ') to determine whether the function already exists. However, my host does not seem to support the above code. It should be because the host does not support the wp_mail function. So I used another method to implement it. The main principle is to use the smtp interface to implement // use smtp to send mail (set SMTP according to your own mailbox)
// Use smtp to send emails (set SMTP according to your mailbox) add_action ('phpmailer _ init ', 'mail _ smtp_2'); function mail_smtp_2 ($ phpmailer) {$ phpmailer-> FromName = 'Zhu Haitao self-media '; // sender name $ phpmailer-> Host = 'smtp .qq.com '; // modify the email SMTP server $ phpmailer-> Port = 465; // SMTP Port $ phpmailer-> Username = 'stcash @ stcash.com '; // email account $ phpmailer-> Password = 'xz2015 '; // email Password $ phpmailer-> From = 'stcash @ stcash.com '; // email account $ phpmailer-> SMTPAuth = true; $ phpmailer-> SMTPSecure = 'SSL '; // leave tls or ssl (port = 25-> Blank, 465 Hour-> ssl) $ phpmailer-> IsSMTP ();}
This section
The code is common on the host. You only need to modify the sender name, email SMTP server, and email account.
The port and smtp address of each mailbox are attached:
Email 188 |
Pop3.188.com |
Smtp.188.com |
Port: 25 |
Email 163 |
Pop3.163.com |
Smtp.163.com |
Port: 25 |
Email 126 |
Pop3.126.com |
Smtp.126.com |
Port: 25 |
Netease email |
Pop.netease.com |
Smtp.netease.com |
Port: 25 |
Yeah email |
Pop.yeah.net |
Smtp.yeah.net |
Port: 25 |
QQ mailbox |
Pop.qq.com |
Smtp.qq.com |
Port: 465 or 587 |
Even troublesome webmasters can directly use the following method to send comments and reply emails.