1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
function sendEmail($aTo, $aFrom, $aSubject, $aBody)
{
global $set_ini_smtp, $quiet,$from_address_mail;
if (!$aFrom) { die(failMsg("No sender (Code #100)","No sender is specified.")); }
if (!$aTo) { die(failMsg("No reciept (Code #101)","No recipient is specified.")); }
if (!$aSubject) { die(failMsg("No subject (Code #102)","No subject is specified.")); }
if (!$aBody) { die(failMsg("No body (Code #103)","Nobody is specified.")); }
if ($set_ini_smtp)
ini_set("SMTP",$set_ini_smtp);
$aBody = ereg_replace("<br>","\n",$aBody);
$headers = "From: $aFrom\r\n";
if (!$quiet)
{
if (!validateEmail("$aTo"))
die(failMsg("Problem sending mail","Email address TO: '$aTo' does not appear to be a valid email address."));
if (!validateEmail("$aFrom"))
die(failMsg("Problem sending mail","Email address FROM: '$aFrom' does not appear to be a valid email address."));
if (!mail("$aTo", "$aSubject","$aBody","From: $aFrom\r\n"))
die(failMsg("Problem sending mail","For some reason, one or more emails were not sent. To: $aTo, From: $aFrom, Subject: $aSubject"));
}
else
{
mail("$aTo", "$aSubject","$aBody","From: $aFrom\r\n");
//mail("$aTo", "$aSubject","$aBody","From: $aFrom<$aFrom>\nX-Mailer: PHP 4.x\r\n\r\n");
}
return true;
} |
Partager