Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ew_SendEmail($sFrEmail, $sToEmail, $sCcEmail, $sBccEmail, $sSubject, $sMail, $sFormat, $sCharset) {
- global $Language, $gsEmailErrDesc;
- $res = FALSE;
- if (EW_EMAIL_COMPONENT == "PHPMAILER") {
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->Host = EW_SMTP_SERVER;
- $mail->SMTPAuth = (EW_SMTP_SERVER_USERNAME <> "" && EW_SMTP_SERVER_PASSWORD <> "");
- $mail->Username = EW_SMTP_SERVER_USERNAME;
- $mail->Password = EW_SMTP_SERVER_PASSWORD;
- $mail->Port = EW_SMTP_SERVER_PORT;
- $mail->From = $sFrEmail;
- $mail->FromName = $sFrEmail;
- $mail->Subject = $sSubject;
- $mail->Body = $sMail;
- if ($sCharset <> "" && strtolower($sCharset) <> "iso-8859-1")
- $mail->Charset = $sCharset;
- $sToEmail = str_replace(";", ",", $sToEmail);
- $arrTo = explode(",", $sToEmail);
- foreach ($arrTo as $sTo) {
- $mail->AddAddress(trim($sTo));
- }
- if ($sCcEmail <> "") {
- $sCcEmail = str_replace(";", ",", $sCcEmail);
- $arrCc = explode(",", $sCcEmail);
- foreach ($arrCc as $sCc) {
- $mail->AddCC(trim($sCc));
- }
- }
- if ($sBccEmail <> "") {
- $sBccEmail = str_replace(";", ",", $sBccEmail);
- $arrBcc = explode(",", $sBccEmail);
- foreach ($arrBcc as $sBcc) {
- $mail->AddBCC(trim($sBcc));
- }
- }
- if (strtolower($sFormat) == "html") {
- $mail->ContentType = "text/html";
- } else {
- $mail->ContentType = "text/plain";
- }
- $res = $mail->Send();
- $gsEmailErrDesc = $mail->ErrorInfo;
- // Uncomment to debug
- var_dump($mail); exit();
- } else {
- $to = $sToEmail;
- $subject = $sSubject;
- $message = $sMail;
- // header
- $content_type = (strtolower($sFormat) == "html") ? "text/html" : "text/plain";
- if ($sCharset <> "")
- $content_type .= "; charset=" . $sCharset;
- $headers = "Content-type: " . $content_type . "\r\n";
- $headers .= "From: " . str_replace(";", ",", $sFrEmail) . "\r\n";
- if ($sCcEmail <> "")
- $headers .= "Cc: " . str_replace(";", ",", $sCcEmail) . "\r\n";
- if ($sBccEmail <>"")
- $headers .= "Bcc: " . str_replace(";", ",", $sBccEmail) . "\r\n";
- if (EW_IS_WINDOWS) {
- if (EW_SMTP_SERVER <> "")
- ini_set("SMTP", EW_SMTP_SERVER);
- if (is_int(EW_SMTP_SERVER_PORT))
- ini_set("smtp_port", EW_SMTP_SERVER_PORT);
- }
- ini_set("sendmail_from", $sFrEmail);
- $res = mail($to, $subject, $message, $headers);
- $gsEmailErrDesc = ($res) ? $Language->Phrase("FailedToSendMail") : "";
- // Uncomment to debug
- // echo "Header: " . $headers . "<br>" . "Subject: " . $subject . "<br>" .
- // "To: " . $to . "<br>" . "Body: " . $message . "<br>"; exit();
- }
- return $res;
- }
Add Comment
Please, Sign In to add comment