Automatically update and synchronize wordpress blogs

Source: Internet
Author: User
Tags php file

View my effect chart

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 );

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.