Example #1
0
function sendHtmlMail($toAddress, $subject, $htmlContent, $plainContent)
{
    // Grab our config settings
    require_once $_SERVER["DOCUMENT_ROOT"] . '/phpmailer-2.0.2/config.php';
    require_once $_SERVER["DOCUMENT_ROOT"] . '/phpmailer-2.0.2/FreakMailer.inc';
    $result = "";
    // Grab the FreakMailer class
    // instantiate the class
    $mailer = new FreakMailer();
    $mailer->IsHTML(true);
    $mailer->CharSet = "ISO-8859-1";
    $mailer->ClearAttachments();
    $mailer->From = 'ike@yoursite';
    $mailer->FromName = 'yoursite staff';
    // bounces!!
    $mailer->Sender = 'ike@yoursite';
    // Set the subject
    $mailer->Subject = $subject;
    // Body
    $mailer->Body = $htmlContent;
    $mailer->AltBody = $plainContent;
    // Add an address to send to.
    $mailer->AddAddress($toAddress);
    $mailer->Send();
    $result = $mailer->ErrorInfo;
    $mailer->ClearAddresses();
    $mailer->ClearAttachments();
    return $result;
}
Example #2
0
for ($i = 1; $i <= count($site['to_email']); $i++) {
    $mailer->AddAddress($site['to_email'][$i - 1]);
}
//$mailer->AddAddress('*****@*****.**', 'Bill Leddy');
// add CC addresses
for ($i = 1; $i <= count($site['CC_email']); $i++) {
    $mailer->AddCC($site['CC_email'][$i - 1]);
}
// add BCC addresses
for ($i = 1; $i <= count($site['BCC_email']); $i++) {
    $mailer->AddBCC($site['BCC_email'][$i - 1]);
}
//$mailer->AddBCC('*****@*****.**', 'Bill Leddy');
if (trim($_POST['customer_email']) != '') {
    //Actually send the email
    if (!$mailer->Send()) {
        echo "Fail";
        // use this to dump the mailer info
        // look for ErrorInfo
        //print_r($mailer);
    } else {
        echo "Success";
    }
} else {
    echo "No email sent";
}
// clean up
$mailer->ClearAddresses();
$mailer->ClearAttachments();
$mailer->ClearCustomHeaders();
$mailer->ClearReplyTos();
function functSendEmail($emailaddr, $strSubject, $strBody, $name, $strFromName, $strFromEmail, $strAttachmentFileFullPath, $strEmailType = "text/plain")
{
    //base function to send all emails from webservers smtp service
    if ($strFromName == "") {
        $strFromName = EMAIL_FROM_NAME;
    }
    if ($strFromEmail == "") {
        $strFromEmail = EMAIL_FROM_ADDR;
    }
    // instantiate the class
    $mailer = new FreakMailer();
    // Get From Variable from Constants File
    $mailer->ContentType = $strEmailType;
    if ($strEmailType == "text/html") {
        $strHTMLMime = true;
    } else {
        $strHTMLMime = false;
    }
    $mailer->IsHTML($strHTMLMime);
    $mailer->From = $strFromEmail;
    $mailer->FromName = $strFromName;
    $mailer->Subject = $strSubject;
    $mailer->Body = $strBody;
    if (is_array($emailaddr)) {
        foreach ($emailaddr as $email) {
            $mailer->AddAddress($email, $name);
        }
    } else {
        //send one
        $mailer->AddAddress($emailaddr, $name);
    }
    //now Attach file submitted
    if ($strAttachmentFileFullPath && file_exists($strAttachmentFileFullPath)) {
        $mailer->AddAttachment($strAttachmentFileFullPath);
    }
    if (!$mailer->Send()) {
        $strErrorString = 'There was a problem sending this mail!';
    } else {
        $strErrorString = "sent";
    }
    $mailer->ClearAddresses();
    $mailer->ClearAttachments();
    return $strErrorString;
}