1

I use PHPMailer for PHP5/6 and i try to make script witch will send mail and get error like "550 No Such User Here".

I read about DSN, and try tips from this How to set DSN (Delivery Status Notification) for PHPMailer? topic, but it's doesnt work. (i found functin recipient where was

return $this->sendCommand(
        'RCPT TO',
        'RCPT TO:<' . $toaddr . '>',
        array(250, 251)
    );
)

and i try change link

'RCPT TO:<' . $toaddr . '>',

to

'RCPT TO:<' . $toaddr . '> NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;' . $toaddr ."" .self::CRLF,

but i doesnt work. I was try add it by function AddCustomHeader but it fail too.

This is my code:

private function send($username, $password, $from, $nameFrom, $replay, $subject, $email) {
    try {
        $_ = Zend_Registry::get('Zend_Translate');
        $mail = new PHPMailer(true);

        $mail->IsSMTP();
        $mail->SMTPDebug = 2;
        $mail->SMTPAuth = true;
        $mail->SMTPSecure = "tls";
        $mail->Host = "smtp.gmail.com";
        $mail->Port = 587;
        $mail->SMTPKeepAlive = true;
        $mail->Username = $username;
        $mail->Password = $password;
        $mail->SetFrom($from, $nameFrom);
        $mail->AddReplyTo($replay, $nameFrom);
        $mail->Subject = $subject;
        $mail->MsgHTML($this->_content);
        $mail->AddAddress($email);
//            $mail->AddCustomHeader( "X-Confirm-Reading-To: development.tabi@gmail.com" );
//            $mail->AddCustomHeader( "NOTIFY=SUCCESS,FAILURE ORCPT=rfc822; $email" );
//            $mail->AddCustomHeader( "Disposition-Notification-To: development.tabi@gmail.com" );
//            $mail->AddCustomHeader( "Return-receipt-to: development.tabi@gmail.com" );
        if (!$mail->Send()) {
            return array(
                'status' => false,
                'message' => $mail->ErrorInfo
            );
        } else {
            return array(
                'status' => true,
                'message' => $_->_('__MAIL_WAS_SEND__')
            );
        }
    } catch (Exception $e) {
        return array(
                'status' => false,
                'message' => $e->getMessage()
            );
    }
    catch (phpmailerException $e) {
        return array(
                'status' => false,
                'message' => $e->getMessage()
            );
    }
}

In result i have need script where: When i write real address, ex my_real_addres@gmail.com it will be send, but when i write fake address, ex my_fake_addres_which_not_exist@gmail.com will return me code 550, or any other error.

Is there any options to do this ? becouse i need to get and save all information.

Community
  • 1
  • 1
user2970713
  • 31
  • 1
  • 4

1 Answers1

2

Remember, that due to spambots and e-mail verifying scripts (such as yours). Many mail servers do not send those responses.

If they did, they would be flooded by spambots that would be asking for whole their mail databases (millions of records) if those e-mails exist.

For that reason, it's disabled on most mailservers nowdays.

Sources:

Is there a way to test if an E-Mail address exists without sending a test mail?

How to check if an email address exists without sending an email?

Edit:

Basically, every of those functions can be disabled by server admin. They may even return faked info etc. It's all to make it unsusable to spammers (legit uses got to suffer from this).

There are other methods to verify if e-mail exists. Ask for reply, for delivery confirmation etc.

Some servers when message could not be delivered return you e-mail. But that's not 100% sure behaviour, since spammers could spam servers with random generated e-mails and wait for returns.

Those measures are implemented to pervent spammers with brute-force mass e-mail checks.

They could run dictionary attack against google servers and quickly create list of all existing emails.

Don't know what you want achive, if you want to check if one of your newsletter subscribers deleted e-mail or grabbed e-mail from random site and want to confirm it.

You should follow one principle: All e-mails are unverified by default. You never know if its real or not unless it's been verified by recipent by clicking link, answering etc.
By me, there should be no status as "100% does not exist" since you're unable to verify it.

Community
  • 1
  • 1
Grzegorz
  • 3,538
  • 4
  • 29
  • 47
  • Thanks you for respond. So if i good understand there is a two metods, witch sometimes work, VRFY and RCPT TO. If this method doesnt support, i can only filtred email when i add it to list, nothing more, right ? – user2970713 May 28 '14 at 10:00
  • Updated answer with bit more background of how it works in current world. – Grzegorz May 28 '14 at 10:45
  • posting some links that provides you with some more links is actually a bad answere ^^ – Dwza Jan 05 '15 at 16:59
  • The path to answer is irrelevant. The output is most important here. And duplicating content is not. If you mean: "see more info" in one of answers. Its extension to answer that answer provides. Basically that question answers if its possible. Or so I think :) He did not ask how it works, but if it works. – Grzegorz Jan 09 '15 at 07:40