| | |
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 |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube





