Using CRON with Postman
-
Great plugin, I’m wondering if there can be an improvement over performance of it though.
I have experienced when sending out emails, especially when sending more than one, that the server becomes very unresponsive.
I have modified the definition of wp_mail and have tested a few times and works ok. I’m wondering if you can review making following changes. I am just copying something I have found on Internet, so I do not know if the code is faultless.
In wp_mail, replace with following code.
$args = func_get_args(); $args[] = mt_rand(); wp_schedule_single_event( time() + 5, 'cron_send_mail', $args ); return true,
——————————————————————-
Then add action and functions to handle the scheduled taskadd_action( 'cron_send_mail', 'cron_send_mail', 10, 10 ); function cron_send_mail() { $args = func_get_args(); // Remove the random number that was added to the arguments array_pop( $args ); call_user_func_array( 'postmanmail_cron', $args ); } function postmanmail_cron(){ $args = func_get_args(); // create an instance of PostmanWpMail to send the message $postmanWpMail = new PostmanWpMail (); // send the mail $result = $postmanWpMail->send ($args[0], $args[1], $args[2], $args[3], $args[4] );//$to, $subject, $message, $headers, $attachments ); // return the result return $result; }
- The topic ‘Using CRON with Postman’ is closed to new replies.