Help with Swift Mailer for Beginner
Hi, I have done some research and reading and it sounds like swiftmailer is what I need. However, I can't understand the documentation that is provided in the swiftmailer website. Can someone please give an example of a simple for with a few fields such as name, email, and attachments in the swiftmailer 4.3.0 so I can take it from there? I don't need the form page just the processing page will be great. If not please point me to a site that will have tutorial/sample that have complete from beginning to end code. Thx.
Copy-pasted from the documentation. Just FYI.
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
You could alternatively use a different transport such as Sendmail or Mail:
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
$transport = Swift_MailTransport::newInstance();
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('email@example.com' => 'John Doe'))
->setTo(array('firstname.lastname@example.org', 'email@example.com' => 'A name'))
->setBody('Here is the message itself')
// Optionally add any attachments
// Send the message
$result = $mailer->send($message);
Thanks for the response. The attachment in the document looks like a document that is on my server. What I need is a uploaded file from the user and email it to me and needs to have multiple files. How is that done?
If the file has been uploaded, then it will in fact be on your server. It will be saved at $_FILES['form_control_name']['tmp_name']. (See http://www.php.net/manual/en/feature...ost-method.php)
You can attach as many files as you like by invoking ->attach() as many times as needed.
I think I get it now. But how do I validate those files are images before using swiftmailer to send it? I seen some php script to validate one file but how to validate multiple files? thx.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)