Guest_imported
New member
- Jan 1, 1970
- 0
I have a form that people fill out. Now I am able to grab the data. But the problem is I need to put this data into a file and then send this file as an attachment to an email address. I do not know how to even begin to create the file. I DO however have the capability of sending the email, but it isn't sending the file correctly. all i get is a bunch of letters that make no sense in the email message, instead of the attached file i want. can anyone help.
Here's the code that i have:
$txt = "comma delimited form data"
$filename = "mail/df". $datetimestamp . ".csv";
print "The filename: " . $filename . " has been assigned.";
//opening file to write to
$fp = fopen("$filename","a+"
//writing data to file
$write_data = fputs($fp,$txt);
if (is_file($filename))
{
print $filename . " EXISTS";
print $write_data . "<br>";
//making sure data was written
if ($write_data)
{ print("<CENTER><H3>Successfully added data</H3><BR>(automatic forward in 5 seconds)</CENTER>" }
else
{ print("<CENTER><H3><FONT COLOR='#FF0000'>Unsuccessful</FONT> added data </H3><BR>(automatic forward in 5 seconds)" }
}
include("../slugs/mime_mail.inc"
//Sends the email with the attachment.
$mail=new mime_mail;
$mail->from = "from@mydomain.com";
$mail->to = "to@mydomain.com";
$mail->subject = "Testing Send Mail";
$mail->body = $msg;
$content_type = "plain/text";
$mail->add_attachment($txt,$filename,$content_type);
$mail->send();
fclose($fp);
unlink($filename);
Thank You in advance
Here's the code that i have:
$txt = "comma delimited form data"
$filename = "mail/df". $datetimestamp . ".csv";
print "The filename: " . $filename . " has been assigned.";
//opening file to write to
$fp = fopen("$filename","a+"
//writing data to file
$write_data = fputs($fp,$txt);
if (is_file($filename))
{
print $filename . " EXISTS";
print $write_data . "<br>";
//making sure data was written
if ($write_data)
{ print("<CENTER><H3>Successfully added data</H3><BR>(automatic forward in 5 seconds)</CENTER>" }
else
{ print("<CENTER><H3><FONT COLOR='#FF0000'>Unsuccessful</FONT> added data </H3><BR>(automatic forward in 5 seconds)" }
}
include("../slugs/mime_mail.inc"
//Sends the email with the attachment.
$mail=new mime_mail;
$mail->from = "from@mydomain.com";
$mail->to = "to@mydomain.com";
$mail->subject = "Testing Send Mail";
$mail->body = $msg;
$content_type = "plain/text";
$mail->add_attachment($txt,$filename,$content_type);
$mail->send();
fclose($fp);
unlink($filename);
Thank You in advance