示例#1
0
function getMailSubject()
{
    return 'Workshops and Guest Lectures @ Pragyan\'10 - NIT Trichy\'s Annual Techno-Management Fest';
    // 'Pragyan 2010';
}
function registerMailSent($email)
{
    global $sentFile;
    fwrite($sentFile, $email . "\n");
}
function registerMailSendError($email)
{
    global $errorFile;
    fwrite($errorFile, $email . "\n");
}
$recipients = getRecipientList();
$sender = 'Pragyan 10 <*****@*****.**>';
$replyTo = '*****@*****.**';
$subject = getMailSubject();
$message = getMailContents();
for ($i = 0; $i < count($recipients); ++$i) {
    echo "Mailing {$recipients[$i]}... ";
    $headers = "From: {$sender}\r\n" . "Reply-To: {$replyTo}\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/alternative; boundary=\"000708050804010404000804\"";
    if (@mail($recipients[$i], $subject, $message, $headers)) {
        echo "Success\n";
        registerMailSent($recipients[$i]);
    } else {
        echo "Failure\n";
        registerMailSendError($recipients[$i]);
    }
}
示例#2
0
function sendMailLocalUse($action, $group)
{
    include_once 'Mail.php';
    include_once 'Mail/mime.php';
    global $input;
    $subject = getMailSubject($action);
    $html = getMailContent($action);
    $cursor = mongoFind(DB, 'priviledge', array('role' => $group, 'country' => $_SESSION['location']), array('user' => true));
    $pushedArray = array();
    while ($cursor->hasNext()) {
        $r = $cursor->getNext();
        array_push($pushedArray, $r['user']);
    }
    $recipient = array('to' => array());
    foreach ($pushedArray as $userName) {
        $email = getEmailFromUserAccount($userName);
        array_push($recipient['to'], $email[0]['mail'][0]);
    }
    /* SMTP server name, port, user/passwd */
    $smtpInfo = array("host" => "10.16.11.68", "port" => "25", "auth" => false);
    $recipients = join(',', $recipient['to']) . (isset($recipient['cc']) ? ', ' . $recipient['cc'] : '') . (isset($recipient['bcc']) ? ', ' . $recipient['bcc'] : '');
    $crlf = "\n";
    $headers = array("From" => "*****@*****.**", "To" => join(',', $recipient['to']), "Subject" => $subject);
    if (isset($recipient['cc'])) {
        $headers['Cc'] = $recipient['cc'];
    }
    if (isset($recipient['bcc'])) {
        $headers['Bcc'] = $recipient['bcc'];
    }
    /*Creating the Mime message*/
    $mime = new Mail_mime($crlf);
    /*Setting the body of the email*/
    /*$mime->setTXTBody($body);*/
    $mime->setHTMLBody($html);
    $body = $mime->get();
    $headers = $mime->headers($headers);
    /* Create the mail object using the Mail::factory method */
    $mail_object =& Mail::factory("smtp", $smtpInfo);
    /* Ok send mail */
    $mail_object->send($recipients, $headers, $body);
    error_log(currentTime() . $subject . ' ' . 'e-mail has been sent to' . ' ' . $recipients);
}