Can anyone give me some tips on how to attach a file to the confirmation file of a web form.
I found how to upload files by the user and send them off but what i want achieve is: Users fills in the form, the receive an html email with all the data they provided. I would like to attach a pdf file with terms & conditions and a doc or pdf file with additional information about the course. All the files are on my server.
I have red about that but I have set everything up and running with the mail(); I am not familiar with the phpmailer or swiftmailer library. Omoutop Do you have an example or a short explination on how it works?
// include the lilbrary require_once $_SERVER['DOCUMENT_ROOT'].'/mailer/swift/lib/swift_required.php'; // set transport method - this is for mail().. in manual options for smpt $transport = Swift_MailTransport::newInstance(); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport);
// $messageTEXT is your non-html message // $messageHTML is yout html message // $attachFile path to your local file
// Create the message $message = Swift_Message::newInstance() // Give the message a subject ->setSubject('subject here') // Set the From address with an associative array ->setFrom(array('firstname.lastname@example.org' => Website Autoreport') // Set Return Address ->setReturnPath('email@example.com') // Set the To addresses with an associative array ->setTo(array('firstname.lastname@example.org'=>'Customer name')) // Set the Bcc addresses with an associative array ->setBcc(array('email@example.com'=>'Test1', 'firstname.lastname@example.org')) // Set character set ->setCharset('utf-8') // Set Priority to Normal (1:Highest -> 5:very low) ->setPriority(2) // Give it a body ->setBody($messageTEXT) // And optionally an alternative body ->addPart($messageHTML, 'text/html') // attache file $message->attach(Swift_Attachment::fromPath($attachFile));
// Send the message $result = $mailer->send($message);