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.