Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'phpmailer/vendor/phpmailer/phpmailer/src/Exception.php';
- require 'phpmailer/vendor/phpmailer/phpmailer/src/PHPMailer.php';
- require 'phpmailer/vendor/phpmailer/phpmailer/src/SMTP.php';
- require 'phpmailer/vendor/autoload.php';
- $mail = new PHPMailer(true);
- $USERNAME = "SEU EMAIL AQUI";
- $PASSWORD = "A SENHA DO SEU EMAIL AQUI";
- $NAME_FROM = "NOME";
- $mail->WordWrap = 50;
- $mail->isHTML(true);
- $mail->SMTPSecure = 'ssl';
- $mail->isSMTP();
- $mail->SMTPDebug = 0;
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 465;
- $mail->SMTPAuth = true;
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => false
- )
- );
- $email_destino_principal = "xxxxxxxx@xxxxxxxx.com";
- $email_destino_secundario = "xxxxxxxx@xxxxxxxx.com";
- $html = "AQUI VOCÊ COLOCA O CONTEÚDO DA MENSAGEM";
- try {
- $subject = "AQUI O ASSUNTO";
- $mail->Username = $USERNAME;
- $mail->Password =$PASSWORD;
- $mail->setFrom($USERNAME,$NAME_FROM);
- $mail->addAddress($email_destino_principal);
- $mail->AddCC($email_destino_secundario);
- $mail->Subject = ($subject);
- $mail->msgHTML($html);
- $mail->send();
- echo 'Email enviado com suesso!';
- } catch (Exception $e) {
- echo 'Não foi possível enviar email';
- echo 'Aconteceu o seguinte erro: ' . $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement