Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 3rd, 2009, 08:38 AM
aravindhrm aravindhrm is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 8 aravindhrm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 48 sec
Reputation Power: 0
VBScript - Email - Php Email with attach file

Hello friends,

I am new to php.. i want to send email with attach the file .. anybody know pls send me the coding

Reply With Quote
  #2  
Old September 3rd, 2009, 08:51 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,461 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Day 16 h 50 m 26 sec
Reputation Power: 1806
Quote:
Originally Posted by aravindhrm
Hello friends,

I am new to php.. i want to send email with attach the file .. anybody know pls send me the coding

--> Moved to General Programming Forum

I'm afraid I dont know anything about PHP but a quick Google search returned these results. The first result looks like it should do what you need.

Reply With Quote
  #3  
Old September 4th, 2009, 06:33 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,880 Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)  Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 8 h 47 m 8 sec
Reputation Power: 967
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Here. You'll need to use something like this. And since I'm nice, it also auto-detects the mime-type of the attached file.
php Code:
Original - php Code
  1. <?php
  2. //define the receiver of the email
  3. define('MAIL_RCPT') = 'youraddress@example.com';
  4.  
  5. //define the sender of the email
  6. define('MAIL_SENDER') = 'webmaster@example.com';
  7.  
  8. //define the subject of the email
  9. define('MAIL_SUBJECT') = 'Test email with attachment';
  10.  
  11. //supply the text and html versions of your email message
  12. $text = '';
  13. $html = '';
  14.  
  15. //provide path to the file to be attached
  16. $file = '';
  17.  
  18. //create a boundary string. It must be unique
  19. //so we use the MD5 algorithm to generate a random hash
  20. $random_hash = md5(date('r', time()));
  21.  
  22. //define the headers we want passed. Note that they are separated with \r\n
  23. $headers = 'From: ' . MAIL_SENDER . "\r\nReply-To: " . MAIL_SENDER;
  24.  
  25. //add boundary string and mime type specification
  26. $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash}\"";
  27.  
  28. //read the atachment file contents into a string,
  29. //encode it with MIME base64,
  30. //and split it into smaller chunks
  31. $attachment = chunk_split(base64_encode(file_get_contents($file)  ));
  32.  
  33. //define the body of the message.
  34. $body = "--PHP-mixed-{$random_hash}\r\n"
  35.       . "Content-Type: multipart/alternative; boundary=\"PHP-alt-{$random_hash}\"\r\n"
  36.       . "--PHP-alt-{$random_hash}\r\n"
  37.       . "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
  38.       . "Content-Transfer-Encoding: 7bit\r\n\r\n"
  39.       . "{$text}\r\n\r\n"
  40.       . "--PHP-alt-{$random_hash}\r\n\r\n"
  41.       . "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
  42.       . "Content-Transfer-Encoding: 7bit\r\n\r\n"
  43.       . "{$html}\r\n\r\n"
  44.       . "--PHP-alt-{$random_hash}--\r\n\r\n"
  45.       . "--PHP-mixed-{$random_hash}\r\n"
  46.       . "Content-Type: " . mime_content_type($file) . "; name=\"" . basename($file) . "\"\r\n"
  47.       . "Content-Transfer-Encoding: base64\r\n"
  48.       . "Content-Disposition: attachment\r\n\r\n"
  49.       . "{$attachment}\r\n"
  50.       . "--PHP-mixed-{$random_hash}--\r\n\r\n";
  51.  
  52. //send the email
  53. $mail_sent = @mail(MAIL_RCPT, MAIL_SUBJECT, $body, $headers );
  54. ?>
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Last edited by Nilpo : September 4th, 2009 at 06:35 AM.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > VBScript - Email - Php Email with attach file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek