Coming from my previous question here Swiftmailer message form I don't know how to handle the else part of the code. I mean what do i do if I do not want to attache file while sending email ? Nota Bene: This is no duplicate, There have never been any clear explanation of how to handle the else part of this code. If there is any , please I would like to see the link.
if (isset($_FILES['fileToUpload'])){
$message->attach(
Swift_Attachment::fromPath($_FILES['fileToUpload']['tmp_name'])->setFilename($_FILES['fileToUpload']['name'])
);
}
else{
{what geos here?}
}
I got this on here, but it repeated the sending header in the while part of the code. Any way to avoid repetition?
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
}