Exemplo n.º 1
0
function send_email_exchange($user, $pw, $supporter_KEY, $contact_array)
{
    global $db;
    $sql = 'select Email,First_Name, Last_Name from supporter where supporter_KEY =' . $supporter_KEY;
    $S = $db->Execute($sql) or die($db->errorMsg());
    $s = $S->FetchRow();
    $contact_array['supporter_KEY'] = $supporter_KEY;
    #replace the merge fields
    $contact_array['Notes'] = str_replace('[[First_Name]]', $s['First_Name'], $contact_array['Notes']);
    $contact_array['Notes'] = str_replace('[[Last_Name]]', $s['Last_Name'], $contact_array['Notes']);
    $contact_array['Notes'] = stripcslashes($contact_array['Notes']);
    #testing send
    #echo '<pre>';
    #echo $s['Email'].'<br>';
    #echo $contact_array['Codes'].'<br>';
    #echo $contact_array['Notes'].'<br>';
    #print_r($contact_array);
    #echo '</pre>';
    #send to exchange
    $exchangeclient = new ExchangeClient();
    #$exchangeclient->init($user,$pw , NULL, EXCHANGE_SERVER);
    #$send = $exchangeclient->send_message($s['Email'], $contact_array['Codes'],$contact_array['Notes'], 'HTML',true, false);
    $exchangeclient->init($user, $pw);
    $send = $exchangeclient->send_message($s['Email'], $contact_array['Codes'], $contact_array['Notes'], 'HTML', true, false);
    $contact = new ContactHistory($contact_array);
    $contact->data['supporter_KEY'] = $supporter_KEY;
    $contact->save();
    #save_contact($supporter_KEY, $contact_array);
    echo $x . 'emails sent';
}
Exemplo n.º 2
0
function send_email_php($supporter_KEY, $contact_array)
{
    global $db;
    $sql = 'select Email from supporter where supporter_KEY =' . $supporter_KEY;
    $S = $db->Execute($sql) or die($db->errorMsg());
    $s = $S->FetchRow();
    $to = $s['Email'];
    $from = $contact_array['email_from_email'];
    $name = $contact_array['email_from_name'];
    $subject = $contact_array['Codes'];
    $email = $contact_array['Notes'];
    $headers[] = "MIME-Version: 1.0";
    $headers[] = "Content-type: text/plain; charset=iso-8859-1";
    $headers[] = "From: " . $name . " <" . $from . ">";
    $headers[] = "Reply-To: " . $name . " <" . $from . ">";
    $headers[] = "Subject: {$subject}";
    $headers[] = "X-Mailer: PHP/" . phpversion();
    mail($to, $subject, $email, implode("\r\n", $headers));
    $contact = new ContactHistory($contact_array);
    $contact->data['supporter_KEY'] = $supporter_KEY;
    $contact->save();
}