I'm trying to send emails via PHPMailer and it's working pretty fine. There's just one problem and I do not know how to fix it. There is the possibility, that I might need to try to send emails to an invalid address due to a non existing domain. It's fine that those emails won't be sent as the domain doesn't exist. When I try to, I get an error message and PHPMailer stops and will also not continue sending emails to other (valid) addresses. Is there any way to kind of skip those invalid emails and force PHPMailer to continue without showing error messages?
Error messages:
Fatal error: Uncaught PHPMailer\PHPMailer\Exception: SMTP Error: The following recipients failed: [email protected]: Domain does not exist: 'dummyverein.de' in...
SERVER -> CLIENT: 521 5.1.2 Domain does not exist: 'dummyverein.de'
SMTP ERROR: RCPT TO command failed: 521 5.1.2 Domain does not exist: 'dummyverein.de'
Code:
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$mail->isSMTP();
$mail->isHTML(true);
$mail->Host = 'smtp.strato.de';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'xxxx';
$mail->Password = 'xxxx';
$mail->SMTPSecure = 'tls';
$mail->SMTPDebug = 2; // set to 2 to get error messages for now
$mail->MailerDebug = false;
$mail->setFrom($absender, $name);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->Body = $message_other_player;
$mail->send();
@
before$mail->send();
– Jackleg@$mail->send();
? – Evette@$mail->send();
– Jackleggethostbyname ( string $hostname ) : string
. php.net/manual/de/function.gethostbyname.php – Rancor