Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29925

Why is PHPMailer not sending an email when I get no error [duplicate]

$
0
0

This question already has an answer here:

I am trying to send an email using PHPMailer on a localhost. I want to send the email to my own gmail account using this code:

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'C:/xampp/composer/vendor/autoload.php';

include_once('C:/xampp/phpmailer-master/class.phpmailer.php');

require_once('C:/xampp/phpmailer-master/class.smtp.php');

    $mail = new PHPMailer(true);

    try {
        $mail->SMTPDebug = 3;                   
        $mail->isSMTP();                       
        $mail->Host = 'smtp.gmail.com;';    
        $mail->SMTPAuth = true;               
        $mail->Username = 'email@gmail.com';     
        $mail->Password = 'password1234';         
        $mail->SMTPSecure = true;            
        $mail->Port = 587;

        $mail->From = "email@gmail.com";           
        $mail->FromName = "Wide World";           

        $mail->smtpConnect(
            array(
                "ssl" => array(
                    "verify_peer" => false,
                    "verify_peer_name" => false,
                    "allow_self_signed" => true
                )
            )
        );

        $mail->addAddress("email@gmail.com");

        $mail->isHTML(true);

        $mail->Subject = "Subject Text";
        $mail->Body = "<i>Mail body in HTML</i>";
        $mail->AltBody = "This is the plain text version of the email content";

        echo "Mail has been sent succesfully!";
    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }
}

But when I run it in my browser this is the output says the email was succesfully sent en shows no errors. I have checked the error log in apache and it is empty too.

2019-11-26 14:05:18 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ),)
2019-11-26 14:05:18 Connection: opened
2019-11-26 14:05:18 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP r2sm14848179wrp.64 - gsmtp
2019-11-26 14:05:18 CLIENT -> SERVER: EHLO localhost
2019-11-26 14:05:18 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [145.44.68.125]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2019-11-26 14:05:18 CLIENT -> SERVER: STARTTLS
2019-11-26 14:05:18 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2019-11-26 14:05:18 CLIENT -> SERVER: EHLO localhost
2019-11-26 14:05:18 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [145.44.68.125]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2019-11-26 14:05:18 CLIENT -> SERVER: AUTH LOGIN
2019-11-26 14:05:18 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2019-11-26 14:05:18 CLIENT -> SERVER: [credentials hidden]
2019-11-26 14:05:18 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2019-11-26 14:05:18 CLIENT -> SERVER: [credentials hidden]
2019-11-26 14:05:19 SERVER -> CLIENT: 235 2.7.0 Accepted
Mail has been sent succesfully!2019-11-26 14:05:19 CLIENT -> SERVER: QUIT
2019-11-26 14:05:19 SERVER -> CLIENT: 221 2.0.0 closing connection r2sm14848179wrp.64 - gsmtp
2019-11-26 14:05:19 Connection: closed

It does not show an error yet it doesn't send anything.

Help me out please :)


Viewing all articles
Browse latest Browse all 29925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>