The above link content is roughly sent to the blogmail@188.com, Mail title for the article title, Mail content for the article content this is simple
Run the code directly. The following is the encapsulated method. Add it to the function. Php file under the topic.
The reason is that a new user in the group does not know where the function. php file is located. The path is "root directory \ wp-content \ themes \ topic directory/function. php"
The code is as follows: |
Copy code |
Function auto_send_to_163 ($ mail_info, $ get_data ){ If (get_post_meta ($ get_data ['post _ id'], '_ auto_send_to_163 ')){ Echo get_permalink ($ get_post_id). "synchronized". $ website. "<br/> \ n "; Return false; } Require_once ABSPATH. WPINC. '/class-phpmailer.php '; Require_once ABSPATH. WPINC. '/class-smtp.php '; $ Mail = new PHPMailer (); $ Mail-> IsSMTP (); $ Mail-> Host = $ mail_info ['host']; $ Mail-> CharSet = "UTF-8 "; $ Mail-> SMTPAuth = TRUE; // enable SMTP verification $ Mail-> Username = $ mail_info ['username']; $ Mail-> Password = $ mail_info ['password']; // Post Office password $ Mail-> From = $ mail_info ['username']; $ Mail-> FromName = "Komatsu blog "; $ Mail-> AddAddress ("blogmail@188.com ",""); $ Mail-> Subject = $ get_data ['post _ title']; // mail title $ Mail-> Body = $ get_data ['post _ content']; // mail content $ Mail-> Send (); Add_post_meta ($ get_data ['post _ id'], '_ auto_send_to_163', '1', true ); } |
If you want to add the following code to the NetEase Blog in real time
The code is as follows: |
Copy code |
Function auto_send_to_163 ($ post_ID ){ $ Get_post_info = get_post ($ post_ID ); $ Get_post ['post _ content'] = $ get_post_info-> post_content; $ Get_post ['post _ title'] = $ get_post_info-> post_title; $ Get_post ['post _ id'] = $ post_ID $ Xmlclient ['username'] = ''; // NetEase Blog username $ Xmlclient ['password'] = ''; // NetEase Blog password $ Xmlclient ['host'] = 'smtp .163.com '; Auto_send_to_163 ($ xmlclient, $ get_post ); } Add_action ('Publish _ post', 'Send _ to_boke ', 0 ); |