Jump to content

emailing a .csv


studentofstone

Recommended Posts

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 = "michael@davisgutierrez.com";
$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.