First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// Include to setup the phpmailer class and send a message
|
||||
//
|
||||
|
||||
include_once "class.phpmailer.new.php";
|
||||
|
||||
if (!function_exists('SendEmail')) {
|
||||
function SendEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply = "", $emailRecipient = "", $attachments = array(), $templateFile = "", $emailSender = "") {
|
||||
global $error_message, $ApplicationURLS;
|
||||
|
||||
// Perform some basic validation on the email addresses
|
||||
if (strlen($emailTo) == 0) {
|
||||
$error_message = "emailTo not defined";
|
||||
return(0);
|
||||
}
|
||||
if (strlen($emailFrom) == 0) {
|
||||
$error_message = "emailFrom not defined";
|
||||
return(0);
|
||||
}
|
||||
|
||||
$emailTo = str_replace(" ","",$emailTo);
|
||||
$emailTo = str_replace(",",".",$emailTo);
|
||||
|
||||
$emailFrom = str_replace(" ","",$emailFrom);
|
||||
$emailFrom = str_replace(",",".",$emailFrom);
|
||||
|
||||
if (!preg_match("/^[^@]+@[a-z0-9-]+(\.[a-z0-9-]{2,40}){1,4}$/",$emailTo)) {
|
||||
$error_message = "emailTo bad format";
|
||||
return(0);
|
||||
}
|
||||
if (!preg_match("/^[^@]+@[a-z0-9-]+(\.[a-z0-9-]{2,40}){1,4}$/",$emailFrom)) {
|
||||
$error_message = "emailFrom bad format";
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// Create and configure the mail object
|
||||
$mailObject = new PHPMailer(false); //New instance, with exceptions disabled
|
||||
|
||||
$mailObject->SMTPAuth = true; // enable SMTP authentication
|
||||
$mailObject->Port = 25; // set the SMTP server port
|
||||
$mailObject->Host = "localhost"; // SMTP server
|
||||
$mailObject->Username = "schoolappointments"; // SMTP server username
|
||||
$mailObject->Password = "Online3214++.."; // SMTP server password
|
||||
$mailObject->CharSet = "UTF-8";
|
||||
|
||||
$mailObject->IsSendmail(); // tell the class to use Sendmail
|
||||
|
||||
$mailObject->ClearAddresses();
|
||||
$mailObject->ClearAllRecipients();
|
||||
$mailObject->ClearAttachments();
|
||||
|
||||
if (strlen($emailSender) == 0) $emailSender = "mail@hotlunches.net";
|
||||
$emailSender = $emailFrom;
|
||||
$emailSenderName = $emailReply;
|
||||
// $emailSender = "mail@hotlunches.net";
|
||||
// $emailSenderName = "Hot Lunches Online";
|
||||
|
||||
$mailObject->AddReplyTo($emailFrom, $emailReply);
|
||||
$mailObject->SetFrom($emailSender, $emailSenderName, 1);
|
||||
$mailObject->Sender = $emailSender;
|
||||
$mailObject->From = $emailSender;
|
||||
|
||||
$mailObject->AddAddress($emailTo, $emailRecipient);
|
||||
$mailObject->Subject = $emailSubject;
|
||||
|
||||
$mailObject->IsMail(); // tell the class to use Mail
|
||||
$mailObject->IsSMTP(); // tell the class to use SMTP
|
||||
$mailObject->IsSendmail(); // tell the class to use SendMail
|
||||
|
||||
// Process a template if one is passed
|
||||
if (isset($templateFile) && strlen($templateFile) && is_file($templateFile)) {
|
||||
$template = file_get_contents($templateFile);
|
||||
}
|
||||
|
||||
$emailMessage = htmlspecialchars_decode($emailMessage,ENT_QUOTES);
|
||||
$emailMessage = preg_replace("#&#","&",$emailMessage);
|
||||
|
||||
|
||||
// Use template if available
|
||||
if (isset($template) && strlen($template)) {
|
||||
$Message = str_replace("{EMAIL_BODY_TEXT}",$emailMessage,$template);
|
||||
$mailObject->MsgHTML($Message);
|
||||
}
|
||||
else {
|
||||
if (strip_tags($emailMessage) == $emailMessage) {
|
||||
// Send as a plain text message
|
||||
$mailObject->Body = $emailMessage;
|
||||
}
|
||||
else {
|
||||
// Send HTML message
|
||||
$mailObject->MsgHTML($emailMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Attach any attachments
|
||||
if (is_array($attachments) && count($attachments) > 0) {
|
||||
for ($i = 0; $i < count($attachments); $i++) {
|
||||
$file = $attachments[$i];
|
||||
if (is_file($file)) {
|
||||
$mailObject->AddAttachment($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send message
|
||||
$mailObject->Send();
|
||||
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user