Hello Everyone,
I have used Zend f-2 to send emails to through cronjob. emails are sending sing and multiple perfectly.
That is working perfectly. what I would like to know is when There is wrong email address given ( for example : abc@abc.com ) I could not get any exception or error and returned it true. and on my email I received address not found
after sending email I am updating records that email has been sent. I would like to know how can i determine email has not sent successfully ( in the incorrect email case ) thanks You
my send function looks like this in Service
$mail = new Mail\Message();
$mail->setEncoding('UTF-8');
$html = new MimePart($content);
$html->type = 'text/html';
$html->charset = 'UTF-8';
$bodyParts = [$html];
$body = new MimeMessage();
$body->setParts($bodyParts);
$mail->setBody($body);
if (!$from) {
$from = $this->config['email_addresses']['info'];
}
$mail->setFrom($from);
$mail->addTo($to);
$mail->setEncoding('UTF8');
$mail->setSubject($subject);
if ($this->config['useSmtp'] === true) {
// Die extra Config Felder müssen entfernt werden,
// da die Klasse SmtpOptions sonst nach einem Setter fragt den es nicht gibt.
unset($this->config['email_addresses']);
unset($this->config['useSmtp']);
$transport = new Smtp();
$transport->setOptions(new SmtpOptions($this->config));
} else {
$transport = new Sendmail();
}
$sent = true;
// Email senden
try {
$transport->send($mail);
} catch (\Exception $exception) {
$sent = false;
throw $exception;
}
return $sent;