Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function smtpMailer($para, $de, $de_nome, $assunto, $corpo)
- {
- $path = __DIR__.'/../../view/mail/'.$corpo.'.html';
- if (file_exists($path)) {
- $arquivo = file_get_contents($path);
- global $error;
- $mail = new PHPMailer();
- $mail->IsSMTP(); // Ativar SMTP
- $mail->SMTPDebug = 0; // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
- $mail->SMTPAuth = true; // Autenticação ativada
- $mail->SMTPSecure = 'ssl'; // SSL REQUERIDO pelo GMail
- $mail->Host = 'smtp.gmail.com'; // SMTP utilizado
- $mail->Port = 465; // A porta 587 deverá estar aberta em seu servidor
- $mail->Username = '';
- $mail->Password = '';
- $mail->SetFrom($de, $de_nome);
- $mail->Subject = utf8_decode($assunto);
- $mail->Body = utf8_decode($arquivo);
- $mail->IsHTML(true);
- $mail->AddAddress($para);
- if (!$mail->Send()) {
- $error = 'Mail error: '.$mail->ErrorInfo;
- return false;
- } else {
- $error = 'Mensagem enviada!';
- return true;
- }
- } else {
- $error = 'Arquivo não encotrado';
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement