monkeymade Posted April 15, 2007 Share Posted April 15, 2007 OK, I have been working on this for about 5 days now.... I am trying to make a script that will send an email with an attachement.... Here is the code, started from the where I start to insert the file: $fileatt_type = $filetype; $fileatt_name = $nameuse; $usefile = "/home/bodenpho/public_html/uploads/$nameuse"; $file = fopen($usefile,'rb'); $data = fread($file,filesize($usefile)); fclose($file); $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}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $data = chunk_split(base64_encode($data)); $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($to, $subject, $message, $headers); if ($ok) { } else { echo "<p>Mail could not be sent. Sorry!</p>"; } Ok, when I run this, I am getting the file in my e-mail, but, its not in a useable form. Instead of getting the picture, I get a ton of lines of code for the picture, not exactly what I was hoping for lol. Someone tell me what I am doing wrong please Link to comment https://forums.phpfreaks.com/topic/47132-more-mail-problems/ Share on other sites More sharing options...
monkeymade Posted April 15, 2007 Author Share Posted April 15, 2007 oh, if you want to see what its outputting in my e-mail, I'd be happy to show you, but I think you probably already know what I am talking about.... Link to comment https://forums.phpfreaks.com/topic/47132-more-mail-problems/#findComment-229824 Share on other sites More sharing options...
neel_basu Posted April 15, 2007 Share Posted April 15, 2007 Try this http://zigmoyd.sourceforge.net/man/mail.php#mailIts very Simple Here <?php //Sending Mails With Extra Headers Simply By Using Headers Arrays $ext["Cc"] = "demo1@localhost, demo2@localhost"; $ext["Bcc"] = "postmaster@localhost, admin@localhost"; $ext["attach"] = "atch.txt,test.wav"; $mail = new mail("admin@localhost", "Mail Subject", "Mail Body", $ext); if(!$mail->send()) { echo "Mail Not Sent Succfully\n"; print_r($mail->error);//Print The Errors } else { echo "Mail Sent Successfully\n"; } ?> But Please Read the Installation Instruction before Using http://zigmoyd.sourceforge.net/man/index.php Link to comment https://forums.phpfreaks.com/topic/47132-more-mail-problems/#findComment-229826 Share on other sites More sharing options...
monkeymade Posted April 15, 2007 Author Share Posted April 15, 2007 maybe its just me, but the errors I get with that system are nuts lol Link to comment https://forums.phpfreaks.com/topic/47132-more-mail-problems/#findComment-229896 Share on other sites More sharing options...
neel_basu Posted April 16, 2007 Share Posted April 16, 2007 but the errors I get with that system are nuts lol I didn't Understand. Link to comment https://forums.phpfreaks.com/topic/47132-more-mail-problems/#findComment-230151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.