studentofstone Posted January 4, 2011 Share Posted January 4, 2011 I am trying to set up a script that will capture a form's data, create a .csv and email it. The code I have returns no errors but will not send the email. Any help please. <?php $cr = "\n"; $csvdata = "First Name" . ',' . "Last Name" . ',' . "Email" . ',' . "Telephone" . ',' ."Comments" . $cr; $csvdata .= $first_name . ',' . $Last_Name . ','. $email . ',' . $telephone .',' . $comments . $cr; $thisfile = 'member.csv'; $encoded = chunk_split(base64_encode($csvdata)); // create the email and send it off $subject = "new member"; $from = "[email protected]"; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: multipart/mixed; boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n"; $message = ' This is a multi-part message in MIME format. ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello We have attached for you the PHP script that you requested from http://rrwh.com/scripts.php as a zip file. Regards ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: application/octet-stream; name="'; $message .= "$thisfile"; $message .= '" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="'; $message .= "$thisfile"; $message .= '" '; $message .= "$encoded"; $message .= ' ------=_NextPart_001_0011_1234ABCD.4321FDAC-- '; // now send the email mail($email, $subject, $message, $headers, "-f$from"); echo $mail_sent ? "Mail sent" : "Mail failed"; ?> Link to comment https://forums.phpfreaks.com/topic/223311-emailing-a-csv/ Share on other sites More sharing options...
dragon_sa Posted January 4, 2011 Share Posted January 4, 2011 I cant see where you have set the value for $email not sure if it makes any difference but I have always sent mail like this mail("$email", "$subject", "$message", "$headers", "From: $from"); Link to comment https://forums.phpfreaks.com/topic/223311-emailing-a-csv/#findComment-1154422 Share on other sites More sharing options...
dragon_sa Posted January 4, 2011 Share Posted January 4, 2011 also notice haven't defined $mail_sent $mail_sent = @mail("$email", "$subject", "$message", "$headers", "From: $from"); echo $mail_sent ? "Mail sent" : "Mail failed"; Link to comment https://forums.phpfreaks.com/topic/223311-emailing-a-csv/#findComment-1154423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.