|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/owens.enteract/inc/libs/mail/ |
Upload File : |
<?php
require_once('phpmailer/class.phpmailer.php');
function sendMail($fromName,$fromEmail,$toName,$toEmail,$subject,$body,$altBody="To view the message, please use an HTML compatible email viewer.",$writeOutErrors=false){
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 1; // Enables SMTP debug information (for testing) 1 = errors and messages, 2 = messages only
//Global config values
if (SMTP_AUTH == true){$mail->SMTPAuth = SMTP_AUTH;} // Enable SMTP authentication
if (SMTP_USERNAME != ""){$mail->Username = SMTP_USERNAME;} // STMP username
if (SMTP_PASSWORD != ""){$mail->Password = SMTP_PASSWORD;} // SMTP password
if (SMTP_SECURE != ""){$mail->SMTPSecure = SMTP_SECURE;} // Sets the prefix to the server ("ssl" for Gmail)
if (SMTP_HOST != ""){$mail->Host = SMTP_HOST;} // Sets the SMTP server
if (SMTP_PORT > 0){$mail->Port = SMTP_PORT;} // Set the SMTP port for the server
$mail->SetFrom($fromEmail, $fromName);
$mail->AddReplyTo($fromEmail,$fromName);
$mail->Subject = $subject;
$mail->AltBody = $altBody;
$mail->MsgHTML($body);
$mail->AddAddress($toEmail,$toName);
if(!$mail->Send()) {
return false;
if ($writeOutErrors){
echo "Mailer Error: " . $mail->ErrorInfo;
}
} else {
return true;
}
}
?>