我最多有 5 封电子邮件要通过 Swift Mailer 发送,但我不知道其中有多少是无效的。无效的邮件=“”
我想知道是否有一种方法可以让快速邮件忽略无效的电子邮件,而不是给出致命错误而不发送任何内容。我在网上看了看,我看到他们提到我应该尝试捕捉不良电子邮件,但我不太了解语法或他们试图说的内容,无论如何这是我的代码
//发送欢迎信函数 send_email($info){
//format each email
$body = format_email($info,'html');
$body_plain_txt = format_email($info,'txt');
//setup the mailer
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message ->setSubject('Your Party Information');
$message ->setFrom(array('noreply@stackoverflow.net' => 'noreply@stackoverflow.net'));
$message ->setTo(array($info['Email1'],$info['Email2'],$info['Email3'],$info['Email4'],$info['Email5'] => $info['$firstname']));
$message ->setBody($body_plain_txt);
$message ->addPart($body, 'text/html');
$result = $mailer->send($message);
return $result;
}
$emails1 = $user2['Email'] or " ";
$emails2 = $user2['Email'] or " ";
$emails3 = $user2['Email'] or " ";
$emails4 = $user2['Email'] or " ";
$emails5 = $user2['Email'] or " ";