AnsweredAssumed Answered

How to send emails using cron?

Question asked by Sohan Tirpude on Nov 20, 2014
Hello everyone, I am using SugarCRM 6.5.x community edition. I want send emails using cron. I have no idea how to send emails using cron, so I am postind here my code ...please take a look and let me know if it is correct and if it is then please let me know what to do next. Thank you.

    $query = "SELECT id_c FROM sohan_passwor_management_cstm WHERE ABS(DATEDIFF(NOW(), user_register_datetime_c)) >= 80 AND ABS(DATEDIFF(NOW(), user_register_datetime_c)) < 90)";
    $result = $bean->db->query($query, true);
    while($user_id = $bean->db->fetchByAssoc($result)){
        $emailObj = new Email();
        $defaults = $emailObj->getSystemDefaultEmail();
        $email = new SugarPHPMailer();
        $mail->From = $defaults['email'];
        $mail->FromName = $defaults['name'];
        $mail->Subject="Regarding changing your password."
        $mail->Body="Hello this is testing ....!";
        $mail->AddAddress= $primary_email;

Also please let me know, if there is any other way to make it simple. Thank you