Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

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 Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old February 26th, 2005, 03:14 PM
mobster mobster is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 mobster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Mail() W/ Attachments

Here is the tutorial script now I was just testing this on my server because I like to take things apart and see how they work, but this one doesn't work?

It mail is neverreceived???

Any Suggestions...

Thanks,

php Code:
Original - php Code
  1.  
  2. <?php
  3.  
  4.  
  5. if(!isset($submit)){
  6. ?>
  7. <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"
  8. enctype="multipart/form-data">
  9. <table>
  10. <tr>
  11. <td>To:</td>
  12. <td><input type="text" name="to" size="40"/></td>
  13. </tr>
  14. <tr>
  15. <td>From:</td>
  16. <td><input type="text" name="from" size="40" /></td>
  17. </tr>
  18. <tr>
  19. <td>Subject:</td>
  20. <td><input type="text" name="re" size="40" /></td>
  21. </tr>
  22. <tr>
  23. <td>Message:</td>
  24. <td><textarea cols="30" rows="5" name="comments"></textarea></td>
  25. </tr>
  26. <tr>
  27. <td>Attachment:</td>
  28. <td><input type="file" name="att" size="26" /></td>
  29. </tr>
  30. <td colspan="2"><input type="submit" value="Send Form" /></td>
  31. </tr>
  32. </table>
  33. </form>
  34. <?php
  35. }else{
  36.  
  37.  
  38.         $fp = fopen( $att_name, "r");
  39.  
  40.         $file = fread( $fp, $att_size );
  41.  
  42.         /*
  43. Encode The Data For Transition using base64_encode();
  44. And get a 32-character hexadecimal number
  45. */
  46.         $file = chunk_split(base64_encode($file));
  47.         $num = md5( time() );
  48.  
  49.         /*
  50. Define the main message headers
  51. */
  52.         $hdr  = "From:$fromrn";
  53.         $hdr .= "MIME-Version: 1.0rn";
  54.         $hdr .= "Content-Type: multipart/mixed; ";
  55.         $hdr .= "boundary=$numrn";
  56.         $hdr .= "--$numrn";
  57. /*
  58. Define message section
  59. */
  60.         $hdr .= "Content-Type: text/plainrn";
  61.         $hdr .= "Content-Transfer-Encoding: 8bitrnn";
  62.         $hdr .= "$commentsrn";
  63.         $hdr .= "--$numn";
  64.  
  65.         /*
  66. Define the attachment section
  67. */
  68.         $hdr .= "Content-Type: $att_type; ";
  69.         $hdr .= "name="$att_name"rn";
  70.         $hdr .= "Content-Transfer-Encoding: base64rn";
  71.         $hdr .= "Content-Disposition: attachment; ";
  72.         $hdr .= "filename="$att_name"rnn";
  73.         $hdr .= "$filern";
  74.         $hdr .= "--$num--";
  75.  
  76.         /*
  77. Send the email
  78. */
  79.         mail( '$to', '$re', '$comments', '$hdr');
  80.        
  81.         /*
  82. Close the attachment
  83. */
  84.         fclose( $fp );
  85. }
  86. ?> 


Reply With Quote
  #2  
Old March 23rd, 2005, 08:05 PM
bluephoenix's Avatar
bluephoenix bluephoenix is offline
Levelheaded Curmudgeon
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Syracuse, NY
Posts: 507 bluephoenix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 13 m 2 sec
Reputation Power: 2
Send a message via AIM to bluephoenix
RE: Mail() W/ Attachments

Are there any error messages generated when the mail is sent? If so what are they?

-Tim

Reply With Quote
  #3  
Old April 21st, 2005, 11:44 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Mail() W/ Attachments

try giving your submit button a name:

<input type="submit" value="submit" name="submit">

This isn't the best way of doing it, as if the user submits the form using the enter key, it won't go through, try doing your if statement on something like that to field.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Mail() W/ Attachments


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway