-
-
Save pedroribeirodev/92a248a2125ff845a3adfb1fea37d910 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
<?php | |
if (!session_id()) { | |
session_start(); | |
} | |
define('__ROOT__', dirname(__FILE__)); | |
require_once __ROOT__."/vendor/phpmailer/phpmailer/PHPMailerAutoload.php"; | |
$email = explode(";", $_POST["email"]); | |
if (!function_exists('email')) { | |
/** | |
* @param array|string $email | |
* @param string $assunto | |
* @param string $corpo | |
* @param string @replyTo | |
* @return boolean | |
*/ | |
function email($email = null, $assunto = '(Sem Assunto)', $corpo = null, $replyTo = "[email protected]") | |
{ | |
$mail = new PHPMailer\PHPMailer\PHPMailer(true); | |
try{ | |
$mail->SMTPDebug = 2; | |
$mail->IsSMTP(); | |
$mail->Host = "mail.MEUDOMINIO.com.br"; | |
$mail->SMTPAuth = true; | |
$mail->Username = "[email protected]"; | |
$mail->Password = 'MINHASENHA'; | |
$mail->SMTPSecure = 'tls'; | |
$mail->Port = 587; | |
/*$mail->SMTPOptions = array( | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false, | |
'allow_self_signed' => true | |
) | |
); */ | |
$mail->Priority = 3; | |
$mail->Encoding = 'base64'; | |
$mail->addCustomHeader('Content-Transfer-Encoding', 'base64'); | |
$mail->addCustomHeader('MIME-Version', '1.0'); | |
$mail->SetFrom("[email protected]", "Meu Nome"); | |
$mail->AddReplyTo($replyTo, $replyTo); | |
$mail->isHTML(true); | |
$mail->CharSet = 'utf-8'; | |
$mail->Subject = stripslashes($assunto); | |
$mail->Body = stripslashes($corpo); | |
$mail->AltBody = strip_tags(stripslashes($corpo)); | |
if (is_array($email)) { | |
foreach($email as $addr) | |
{ | |
$mail->addAddress($addr); | |
} | |
} | |
else { | |
$mail->addAddress($email); | |
} | |
$mail->Send(); | |
return true; | |
} | |
catch (PHPMailer\PHPMailer\Exception $e) { | |
echo 'Mensagem não enviada. Erro: ', $mail->ErrorInfo; | |
return false; | |
} | |
} | |
} | |
header("Location: bilhetes.php"); | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment