Created
March 27, 2018 09:05
-
-
Save sidor1989/f6590d48b4e0fac8be823153ab6b7123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
require ($_SERVER["DOCUMENT_ROOT"].'/local/php_interface/phpmailer/PHPMailerAutoload.php'); | |
function custom_mail($to, $subject, $message, $additional_headers, $additional_parameters) { | |
echo "<script>alert('ауе !')</script>"; | |
//return false; | |
$to = str_replace(' ','',$to); | |
#$from="[email protected]"; | |
$fromName="Dental Guru"; | |
#$host="ssl://smtp.gmail.com"; | |
$port=465; | |
#$user="[email protected]"; | |
$from="[email protected]"; | |
#$pass="Siestacompany"; | |
preg_match('/Reply-To: (.+)\n/i', $additional_headers, $matches); | |
list(, $ReplyTo) = $matches; | |
preg_match('/BCC: (.+)\n/i', $additional_headers, $matches); | |
list(, $bcc) = $matches; | |
if (substr_count($additional_headers, "Content-Type: text/html")) | |
{ | |
$mail = new PHPMailer(); | |
#$mail->IsSMTP(); | |
if ($ReplyTo!="") | |
{ | |
$mail->AddReplyTo($ReplyTo); | |
} | |
if ($bcc!="") | |
{ | |
$mail->addBCC($bcc); | |
} | |
$mail->CharSet = 'UTF-8'; | |
$mail->Host = $host; // SMTP server example | |
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing) | |
$mail->SMTPAuth = true; // enable SMTP authentication | |
$mail->Port = $port; // set the SMTP port for server | |
$mail->Username = $user; // SMTP account username example | |
$mail->Password = $pass; // SMTP account password example | |
$mail->From = $from; | |
$mail->FromName = $fromName; | |
$address = explode(',', $to); | |
foreach ($address as $addr) | |
{ | |
$mail->addAddress($addr); | |
} | |
$mail->IsHTML(true); | |
$mail->Subject = $subject; | |
//$mail->Encoding = '8bit'; | |
$bndr = substr(substr($message, 0, 25), -23); // А ВОТ ТУТ МУТИМ СВОЮ МАГИЮ! | |
$mail->ContentType = 'multipart/mixed; boundary="' . $bndr . '"'; | |
$mail->Body = $message; | |
$mail->AltBody = strip_tags(str_replace("<br />","\n",$message)); | |
if (!$mail->send()) | |
{ | |
mail('[email protected]','dental guru smtp error',$mail->ErrorInfo."---------".$additional_headers); | |
return false; | |
exit; | |
} | |
return true; | |
} else | |
{ | |
$mail = new PHPMailer(); | |
#$mail->IsSMTP(); | |
if ($ReplyTo!="") | |
{ | |
$mail->AddReplyTo($ReplyTo); | |
} | |
if ($bcc!="") | |
{ | |
$mail->addBCC($bcc); | |
} | |
$mail->CharSet = 'UTF-8'; | |
$mail->Host = $host; // SMTP server example | |
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing) | |
$mail->SMTPAuth = true; // enable SMTP authentication | |
$mail->Port = $port; // set the SMTP port for the GMAIL server | |
$mail->Username = $user; // SMTP account username example | |
$mail->Password = $pass; // SMTP account password example | |
$mail->From = $from; | |
$mail->FromName = $fromName; | |
$address = explode(',', $to); | |
foreach ($address as $addr) | |
{ | |
$mail->addAddress($addr); | |
} | |
$mail->Subject = $subject; | |
$mail->Body = $message; | |
if (!$mail->send()) | |
{ | |
mail('[email protected]','dental guru smtp error',$mail->ErrorInfo."---------".$additional_headers); | |
return false; | |
exit; | |
} | |
return true; | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment