Dear Friends
I have one doubt in sending uploaded file to mail.
how can i send mail with uploaded file.?
If any one known please post with coding
Thanks and Regards
Umapathy
How to mail uploaded file
Moderator: General Moderators
Get Swift Mailer 
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Wihtout any error checking/sanitization this is how you'd do it with Swift. I should probably use a file upload example in my documentation actually.... I'm going to open the documentation to take user comments which will help.
Code: Select all
if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comment']))
{
//Turn her on
$swift = new Swift(new Swift_Connection_SMTP('smtp.yourhost.tld'));
//Add the message
$swift->addPart($_POST['comment']);
//If a file was uploaded, attach it
if (!empty($_FILES['uploadname']['tmp_name']) && !$_FILES['uploadname']['error']))
{
$swift->attachFile(
file_get_contents($_FILES['uploadname']['tmp_name']),
$_FILES['uploadname']['name'],
$_FILES['uploadname']['type']);
}
//Then send the email
if ($swift->send('your@address', $_POST['email'], 'Subject')) echo "Mail Sent";
else echo "Mail not sent";
$swift->close();
}