PHP auto-Send mail function

Source: Internet
Author: User
Click to view full text

Idea: First set the time in the background, after the setup, the next step is the foreground program

The first step: Execute the JS code that sets the fixed cookie time value in Ajax :

/********** here set the time to start * * * Execute once per minute *********/

$.ajax ({

URL: "Ajax.php?action=time_ajax"

});

/********** here to set the end of the participation time **********/

Step two: Set the cookie value in Ajax

Case ' Time_ajax '://define a fixed timestamp for each minute of execution, which defines a fixed cookie that is not affected by other page refreshes, and depends on your situation

Setcookie ("Fasong_time", Time ());//Record a cookie timestamp

Exit ();

Break

Step Three: Execute the JS code that automatically sends the message :

This step is the JS program that executes when the page is loaded and sends a request to Ajax

Fourth step: Perform auto-send mail

Case ' Fasong_zidong '://Auto-Send mail

/*********** Send mail module start *********/

$now _time = time ();//First to get the current timestamp

$one _data = "The header of the sent message set in the" Select ' Database ', ' the content of the sent message set in the database ', ' The field of the hour set in the database (this is a numeric field) ', ' The field of minutes set in the database (this is a numeric field) ', ' The "from" table name that is set in the database to turn on the automatic sending function;//Query

$one _datas = Query function executes $one_data statement; Write your own query statement here

if ($one _datas[' Is_open ') {//Decide whether to turn on the Send mail feature

if (intval ($now _time-@$_cookie[' fasong_time ') ==intval (the field of the hour set in the $one _data[' database (this is a field of numeric type) ']+ $one _data[' The field of minutes set in the database (this is a numeric field)

Require_once ("fasong.php");//make comparisons between the current timestamp and the length of the background setting

Echo 1;

}

}

/*********** Send mail module end *********/

Exit ();

Break

  • 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.