Last active
July 30, 2018 01:06
-
-
Save apertaoxis/08ad8a42951db5f639af0a573590190a 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 (!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 = retorno@exemplo.com") | |
| { | |
| $mail = new PHPMailer\PHPMailer\PHPMailer(true); | |
| try{ | |
| $mail->SMTPDebug = 0; | |
| $mail->IsSMTP(); | |
| $mail->Host = "mail.host.com"; | |
| $mail->SMTPAuth = true; | |
| $mail->Username = "user@exemplo.com"; | |
| $mail->Password = 'senhasegura123'; | |
| $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("naoresponda@exemplo.com", "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; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment