예제 #1
0
 public function testsendEmail()
 {
     $emailMan = new EmailMan();
     //test without setting any attributes
     $result = $emailMan->sendEmail(new Email(), 1, true);
     $this->assertEquals(false, $result);
     //test with related type attribute set
     $emailMan->related_type = 'Contacts';
     $emailMan->related_id = 1;
     $result = $emailMan->sendEmail(new Email(), 1, true);
     $this->assertEquals(true, $result);
 }
예제 #2
0
                if ($row1['list_type'] == 'exempt_domain') {
                    $emailman->restricted_domains[strtolower($row1['domain_name'])] = 1;
                } else {
                    //find email address of targets in this prospect list.
                    $email_query = "SELECT email_address FROM email_addresses ea JOIN email_addr_bean_rel eabr ON ea.id = eabr.email_address_id JOIN prospect_lists_prospects plp ON eabr.bean_id = plp.related_id AND eabr.bean_module = plp.related_type AND plp.prospect_list_id = '{$row1['prospect_list_id']}' and plp.deleted = 0";
                    $email_query_result = $db->query($email_query);
                    while ($email_address = $db->fetchByAssoc($email_query_result)) {
                        //ignore empty email addresses;
                        if (!empty($email_address['email_address'])) {
                            $emailman->restricted_addresses[strtolower($email_address['email_address'])] = 1;
                        }
                    }
                }
            }
        }
        if (!$emailman->sendEmail($mail, $massemailer_email_copy, $test)) {
            $GLOBALS['log']->fatal("Email delivery FAILURE:" . print_r($row, true));
        } else {
            $GLOBALS['log']->debug("Email delivery SUCCESS:" . print_r($row, true));
        }
        if ($mail->isError()) {
            $GLOBALS['log']->fatal("Email delivery error:" . print_r($row, true) . $mail->ErrorInfo);
        }
    }
    $send_all = $send_all ? !$no_items_in_queue : $send_all;
} while ($send_all == true);
if ($admin->settings['mail_sendtype'] == "SMTP") {
    $mail->SMTPClose();
}
if (isset($temp_user)) {
    $current_user = $temp_user;
                    //find email address of targets in this prospect list.
                    $email_query = " select email1 from prospects  join prospect_lists_prospects on related_id = prospects.id and related_type='Prospects' and prospect_list_id = '{$row1['prospect_list_id']}' and prospect_lists_prospects.deleted=0";
                    $email_query .= " UNION";
                    $email_query .= " select email1 from contacts join prospect_lists_prospects on related_id = contacts.id and related_type='Contacts' and prospect_list_id = '{$row1['prospect_list_id']}' and prospect_lists_prospects.deleted=0";
                    $email_query .= " union";
                    $email_query .= " select email1 from leads join prospect_lists_prospects on related_id = leads.id and related_type='Leads' and prospect_list_id = '{$row1['prospect_list_id']}' and prospect_lists_prospects.deleted=0";
                    $email_query .= " union ";
                    $email_query .= " select email1 from users join prospect_lists_prospects on related_id = users.id and related_type='Users' and prospect_list_id = '{$row1['prospect_list_id']}' and prospect_lists_prospects.deleted=0";
                    $email_query_result = $db->query($email_query);
                    while ($email_address = $db->fetchByAssoc($email_query_result)) {
                        $emailman->restricted_addresses[strtolower($email_address['email1'])] = 1;
                    }
                }
            }
        }
        if (!$emailman->sendEmail($mail, $test)) {
            emaillog("FAILURE:");
        } else {
            emaillog("SUCCESS:");
        }
        emaillog($emailman->toString());
        if ($mail->isError()) {
            emaillog($mail->ErrorInfo);
        }
    }
    $send_all = $send_all ? !$no_items_in_queue : $send_all;
} while ($send_all == true);
if ($admin->settings['mail_sendtype'] == "SMTP") {
    $mail->SMTPClose();
}
if (isset($temp_user)) {