This Question have no Text answers yet!

Detect “Delivery to the following recipient failed permanently” error using PHPMailer

By : dasdasd
Source: Stackoverflow.com
Question!

Im sending email through PHPMailer but sometimes the email addresses that I have are not valid email addresses so I see in my gmail account an email with the error "Delivery to the following recipient failed permanently". I want to catch this error using PHPMailer and to notify the user about this error. When Im trying to send the email PHPMailer does not catch this error, I guess that its some config issue. This is my code:

if(empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL))
                    return BasicServer::serverResponse(Errors::NOT_VALID_PASSWORD_EMAIL_RESTORE, "User email is not valid");


       $mailer = new PHPMailer(true);
        $mailer->isSMTP();

        try {

            $mailer->CharSet        = 'UTF-8';
            $mailer->FromName       = "soInFit";
            $mailer->Host           = "xxxxxx"; // SMTP server
            debug information (for testing)
            $mailer->SMTPAuth       = true;                  // enable SMTP authentication
            $mailer->SMTPSecure     = "ssl";                 // sets the prefix to the servier     
            $mailer->Host           = "smtp.gmail.com";      // sets GMAIL as the SMTP server
            $mailer->Port           = 465;                   // set the SMTP port for the GMAIL server
            $mailer->Username       = "xxxxxx";  // GMAIL username
            $mailer->Password       = 'xxxxx';            // GMAIL password
            $mailer->Subject        = $subject;
            $mailer->Body           = $message;
            $mailer->IsHTML(true); 

            $mailer->addAddress($email);
            if(!$mailer->Send())
                return BasicServer::serverResponse(Errors::UPDATE_ERROR, $mailer->ErrorInfo);

        } catch (phpmailerException $ex) {

            return BasicServer::serverResponse(Errors::UPDATE_ERROR, $ex->errorMessage());
        }
        catch (Exception $e) {
            return BasicServer::serverResponse(Errors::UPDATE_ERROR, $e->errorMessage());
        }
By : dasdasd



PHPMailer SMTP Error 550

My server and php mail() function sends email to the spam folder

How to use PHPmailer? Help me with its API

PHPMailer Lite & GMAIL SMTP: emails not sent to Yahoo Mail, how to debug?

PHP, PHPMailer: Can't get example code for PHPMailer to work

PHPMailer Works on WAMP but not on Production Server

sending email using gmail server [duplicate]

fsockopen returns 'bool(false)' from browser but 'resource(4) of type (stream)' from command line

PHP on GoDaddy Linux Shared trying to send through GMAIL SMTP

PHPMailer or SwiftMailer? [duplicate]

Problem with SMTP emails sent via PhpMailer: Helo Not Accepted

Video about Detect “Delivery to the following recipient failed permanently” error using PHPMailer