Title: Using CRON with Postman
Last modified: August 31, 2016

---

# Using CRON with Postman

 *  [jojungwhan](https://wordpress.org/support/users/jojungwhan/)
 * (@jojungwhan)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/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
   task
 *     ```
       add_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;
       }
       ```
   
 * [https://wordpress.org/plugins/postman-smtp/](https://wordpress.org/plugins/postman-smtp/)

The topic ‘Using CRON with Postman’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/postman-smtp_7c7b78.svg)
 * [Postman SMTP Mailer/Email Log](https://wordpress.org/plugins/postman-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/postman-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/postman-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/postman-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/postman-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/postman-smtp/reviews/)

## Tags

 * [cron](https://wordpress.org/support/topic-tag/cron/)
 * [performance](https://wordpress.org/support/topic-tag/performance/)

 * 0 replies
 * 1 participant
 * Last reply from: [jojungwhan](https://wordpress.org/support/users/jojungwhan/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/using-cron-with-postman/)
 * Status: not resolved