| | |
help in mail attachment
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
hi
In my mail attachment i am able to recieve the attachment but the file size is 0kb.
it is showing the below warnings
please do tell the error in my code
In my mail attachment i am able to recieve the attachment but the file size is 0kb.
it is showing the below warnings
please do tell the error in my code
•
•
•
•
home/wesite/public_html/profiles/resumes/153/
Warning: fopen(home/website/public_html/simple.txt) [function.fopen]: failed to open stream: No such file or directory in /home/website/public_html/mail_attachment.php on line 18
Warning: filesize() [function.filesize]: stat failed for home/website/public_html/simple.txt in /home/website/public_html/mail_attachment.php on line 19
Warning: fread(): supplied argument is not a valid stream resource in /home/wesite/public_html/mail_attachment.php on line 19
Warning: fclose(): supplied argument is not a valid stream resource in /home/website/public_html/mail_attachment.php on line 20
my code
PHP Syntax (Toggle Plain Text)
<?php function mail_attachment ($from , $to, $subject, $message, $attachment){ $attachment="home/website/public_html/simple.txt"; $fileatt = $attachment; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1; $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment $email_from = $from; // Who the email is from $email_subject = $subject; // The Subject of the email $email_txt = $message; // Message that the email has in it $email_to = $to; // Who the email is to $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $msg_txt="\n\nMail created using free code from 4word systems : http://4wordsystems.com"; $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_txt .= $msg_txt; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { } else { die("Sorry but the email could not be sent. Please go back and try again!"); } } ?>
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Solved Threads: 1
queenc:
Interesting that you claim your posted code to be "my" code. As I see it, you copied code from 4word systems (available here: http://www.4wordsystems.com/php_mail_attachment.php).
It's pretty obvious from this line in the code you posted
At the very least, please give credit where credit is due
Steve Szettella
4word systems, inc.
http://www.4wordsystems.com
Interesting that you claim your posted code to be "my" code. As I see it, you copied code from 4word systems (available here: http://www.4wordsystems.com/php_mail_attachment.php).
It's pretty obvious from this line in the code you posted
PHP Syntax (Toggle Plain Text)
$msg_txt="\n\nMail created using free code from 4word systems : http://4wordsystems.com";
Steve Szettella
4word systems, inc.
http://www.4wordsystems.com
![]() |
Similar Threads
- How to view Mail attachments (JSP)
- Monitoring number of smtp bytes sent through python e-mail socket (Python)
- Multimedia Player (Visual Basic 4 / 5 / 6)
- OE E-mail Problems (Windows Software)
- Reading Mail (Java)
- E-mail with Background Sound (Windows NT / 2000 / XP)
- email mail deliver error?? virus? (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Real-Time Currency
- Next Thread: PHP Searching Problem...
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





