Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Cron removes after sometime in wordpress plugin (Advance cron manager)

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Kajal Gaur

User

( 7 months ago )

 

I am using Advance Cron Manager in wordpress for cron, but my cron removes after some time 24-48 hours, I am unable to detect what causing this. I have checked the code and paseted below from my custom plugin. I am using whatsapp chat-api to detect if there is new message received/sent to whatsapp, I am using emails to sent whatsapp message once new email is sent with certain headers, it will hit below function and sent message to whatsapp.

To check this I have scheduled a cron new_email_event after every 1 minute, sometimes it workes ok but some time it removes after 10 minutes.

I want to know is this an issue with plugin or I am missing something.

https://bracketspace.com/downloads/advanced-cron-manager-pro/

This is code written in my custom plugin.

add_action('new_email_event', 'identify_new_email_received');

function identify_new_email_received() {    
    ini_set('display_errors', '1'); 
    $settings = odz_get_whatsappsmtp_settings();    
    include(dirname(__FILE__).'/src/PhpImap/__autoload.php');   

    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = $settings['configured_email'];
    $password = $settings['email_password'];

    $mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', $username, $password);
    //$mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', $settings['configured_email'], $settings['email_password'], __DIR__);                

    $since_date = date('Y-m-d',strtotime("-1 days"));       
    $mailsIds = $mailbox->searchMailbox('SINCE "'.$since_date.'"'); 

    if(!$mailsIds) {
        my_custom_log('No emails');     
    }


    $email_data = array();
    if(!get_site_option('wp_last_email_time')){
        my_custom_log('No last email');
        //whatsapp the last email
        $latest_mail = count($mailsIds) -1;
        $mail = $mailbox->getMail($mailsIds[$latest_mail]);
        $email_data['date'] = $mail->date;
        $email_data['text'] = $mail->textPlain;
        $email_data['id'] = $mail->id;
        $email_data['subject'] = $mail->subject;
        $email_data['fromAddress'] = $mail->fromAddress;
        $email_data['fromName'] = $mail->fromName;
        $sender = get_sender_number($mail->textHtml);
        $msg = get_sender_message($mail->textHtml);
        if(!empty($msg)){
            $email_data['text'] = $msg;
        }

        if(!empty($sender)){
            $mailbox->deleteMail($mail->id);
			
        

what's your interest