•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,680 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,185 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 231 | Replies: 9
![]() |
•
•
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 522
Reputation:
Rep Power: 2
Solved Threads: 53
Hello ...
Try this code..
Try this code..
php Syntax (Toggle Plain Text)
<?php 2. $fileatt = ""; // Path to the file 3. $fileatt_type = "application/octet-stream"; // File Type 4. $fileatt_name = ""; // Filename that will be used for the file as the attachment 5. 6. $email_from = ""; // Who the email is from 7. $email_subject = ""; // The Subject of the email 8. $email_txt = ""; // Message that the email has in it 9. 10. $email_to = ""; // Who the email is too 11. 12. $headers = "From: ".$email_from; 13. 14. $file = fopen($fileatt,'rb'); 15. $data = fread($file,filesize($fileatt)); 16. fclose($file); 17. 18. $semi_rand = md5(time()); 19. $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 20. 21. $headers .= "\nMIME-Version: 1.0\n" . 22. "Content-Type: multipart/mixed;\n" . 23. " boundary=\"{$mime_boundary}\""; 24. 25. $email_message .= "This is a multi-part message in MIME format.\n\n" . 26. "--{$mime_boundary}\n" . 27. "Content-Type:text/html; charset=\"iso-8859-1\"\n" . 28. "Content-Transfer-Encoding: 7bit\n\n" . 29. $email_message . "\n\n"; 30. 31. $data = chunk_split(base64_encode($data)); 32. 33. $email_message .= "--{$mime_boundary}\n" . 34. "Content-Type: {$fileatt_type};\n" . 35. " name=\"{$fileatt_name}\"\n" . 36. //"Content-Disposition: attachment;\n" . 37. //" filename=\"{$fileatt_name}\"\n" . 38. "Content-Transfer-Encoding: base64\n\n" . 39. $data . "\n\n" . 40. "--{$mime_boundary}--\n"; 41. 42. $ok = @mail($email_to, $email_subject, $email_message, $headers); 43. 44. if($ok) { 45. echo "<font face=verdana size=2>The file was successfully sent!</font>"; 46. } else { 47. die("Sorry but the email could not be sent. Please go back and try again!"); 48. } 49. ?> Thanks...
•
•
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 522
Reputation:
Rep Power: 2
Solved Threads: 53
•
•
Join Date: May 2006
Location: ★ ijug.net ★
Posts: 834
Reputation:
Rep Power: 4
Solved Threads: 61
I do not think you will not find many people here who will spoon feed you everything to complete your homework, put some effort first.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Aug 2007
Posts: 147
Reputation:
Rep Power: 0
Solved Threads: 0
Hi.
Thanks for the code,
Just it is working, and the mail sends with the attachment, but i have the following errors while sending:
Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\email\email.php on line 11
Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\email\email.php on line 12
The file was successfully sent!
and secondly, I dont have the email_txt in my mail_box, and also the attachment files not open.
what can be the problem
Thanks for the code,
Just it is working, and the mail sends with the attachment, but i have the following errors while sending:
Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\email\email.php on line 11
Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\email\email.php on line 12
The file was successfully sent!
and secondly, I dont have the email_txt in my mail_box, and also the attachment files not open.
what can be the problem
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 534
Reputation:
Rep Power: 2
Solved Threads: 50
May I present my greatest work utility, let me know if you need help using it:
http://us2.php.net/manual/en/function.fread.php
http://us2.php.net/manual/en/function.fclose.php
http://us2.php.net/manual/en/function.fread.php
http://us2.php.net/manual/en/function.fclose.php
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
access activation advice api blogger blogging blogs chain mail code code injection collaboration tools combo dani daniweb data development dreamweaver dropdownlist emai security email misuse epilepsy gdata google griefers hackers html innovation javascript key mail malware microsoft module net news outlook pop product programming reuse rss serial server source tags vista web wysiwyg xml
- Previous Thread: Change status code
- Next Thread: age caluculation in php...



Linear Mode