Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require("vendor/autoload.php");
- define('SMTP_USER', '****');
- define('SMTP_PASS', '****');
- define('SMTP_HOST', ****);
- define('SMTP_PORT', 587);
- class Mail{
- function send($para, $de, $de_nome, $assunto, $corpo) {
- $mail = new PHPMailer();
- $mail->IsSMTP(); // Ativar SMTP
- $mail->SMTPDebug = 0; // Debug: 1 = erros e mensagens, 2 = mensagens apenas
- $mail->SMTPAuth = true; // Autenticação
- $mail->SMTPSecure = 'tsl'; // SSL Ou TSL
- $mail->Host = SMTP_HOST; // Servidor SMTP utilizado
- $mail->Port = SMTP_PORT; // A porta habilitada no servidor
- $mail->Username = SMTP_USER;
- $mail->Password = SMTP_PASS;
- //Variáveis da mensagem, remetente, assunto, mensagem e destinatário.
- $mail->SetFrom($de, $de_nome);
- $mail->Subject = $assunto;
- $mail->Body = $corpo;
- $mail->AddAddress($para);
- if(!$mail->Send()) {
- return ['status' => false, 'message' => 'Mensagem não enviada: '.$mail->ErrorInfo];
- } else {
- return ['status' => true, 'message' => 'Mensagem enviada com sucesso!'];
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement