Peggy Posted February 22, 2010 Share Posted February 22, 2010 So I'm trying to send a email from a form with an attachment (word doc) . Can anyone help? here is the code that send s the email <?php $css_email = ' <style type="text/css"> div{ width:550px; display:block: } .l_long_nopad{ float:left; display:block; width:140px; text-align:right; margin-right:15px; } p.form{ float:left; clear:left; display:block; width:540px; } </style> '; $to = '[email protected]'; $boundary = '-----=' . md5( uniqid ( rand() ) ); $message ='<html> <head>' .$css_email. '</head> <body> <div> '.$sentance.' </div> </body> </html>'; $message .= "Content-Type: application/msword"; name=".$attachment."\n"; $message .= "Content-Transfer-Encoding: base64 \n"; $message .= "Content-Disposition: attachment; filename=".$attachment."\n\n"; $path = 'uplaods/'.$attachment; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $headers = "From:".$email."\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail($to, $subject, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/193008-email-attatchment/ Share on other sites More sharing options...
jcanker Posted February 22, 2010 Share Posted February 22, 2010 This is the tutorial I used when I had to do this a while back: http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment Link to comment https://forums.phpfreaks.com/topic/193008-email-attatchment/#findComment-1016468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.