来自我之前的问题Swiftmailer message form 我不知道如何处理代码的else部分。我的意思是,如果我不想在发送电子邮件时附带文件,该怎么办? Nota Bene:这没有重复,从未有过如何处理此代码的else部分的明确解释。如果有,请我看看链接。
if (isset($_FILES['fileToUpload'])){
$message->attach(
Swift_Attachment::fromPath($_FILES['fileToUpload']['tmp_name'])->setFilename($_FILES['fileToUpload']['name'])
);
}
else{
{what geos here?}
}
我在这里得到了这个,但它在代码的while部分重复了发送头。有什么办法可以避免重复吗?
else {
//non attach sw code
$message = Swift_Message::newInstance()
->setSubject('Imperial Order') // Message subject
->setTo(array($input1 => $input2, 'ehilse@paifashion.com' => 'Janet McCauley')) // Array of people to send to
->setFrom(array('noreply@paifashion.com' => 'Imperial Order'))
->setBody($html_message, 'text/html') // Attach that HTML message from earlier
}