livegirllove
asked on
get csv and email it
Hi. I need to create a csv and then email it.
I create the csv like this:
$csv .= "$row[id],$row[date],$row[ lead_id],$ row[name], $row[lastn ame],$row[ emailaddre ss],$row[a ddress],$r ow[city],$ row[st],$r ow[zip],$r ow[homepho ne],$row[w orkphone], NA,$row[be st_time_to _call],$ro w[loanpurp ose],$row[ desired_lo an_amount] ,$row[prop ertytype], $row[curre ntvalue],$ row[first_ balance],$ row[rate], NA,$row[lo antype],NA ,LTV,$row[ credit],NA ,NA,NA,NA, $row[ipadd ress]\n";
header('Content-type:appli cation/sav e-as');
header('Content-dispositio n:attachme nt;filenam e='.$CSV_f ilename.'- '.$today.' .csv');
echo $csv;
opens the save as window....
Instead I would like to attach it to an email.
Thanks
I create the csv like this:
$csv .= "$row[id],$row[date],$row[
header('Content-type:appli
header('Content-dispositio
echo $csv;
opens the save as window....
Instead I would like to attach it to an email.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER
$fh = fopen($file, "w");
$file_contents = $csv;
fwrite($fh, $file_contents);
fclose($fh);
$fileatt = "uploads/juicy.csv"; // Path to the file
$fileatt_type = "application/octet-stream"
$fileatt_name = "juicy.csv"; // Filename that will be used for the file as the attachment
$email_from = "support@equotegrabber.com
$email_subject = "leads requested"; // The Subject of the email
$email_txt = "here they are"; // Message that the email has in it
$email_to = "support@solohelp.com"; // Who the email is too
$headers = "From: ".$email_from;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary
$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
$email_message . "\n\n";
$data = chunk_split(base64_encode(
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}
"Content-Transfer-Encoding
$data . "\n\n" .
"--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
echo "<font face=verdana size=2>The file was successfully sent!</font>";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}