db2trade
asked on
Email attachment
Hi,
I know how to send an email using PHP :
$to = $_POST['to'];
$from = 'From: '.$_POST['from'];
$subject = '['.$_POST['tag'].'] '.$_POST['subject'];
$message = $_POST['message'];
mail($to, $subject, $message, $from);
My question is, how can I attach a TEXT file ? Suppose I have a text file called "order.txt" and I want to attach it in the mail.
I need this to send the order to a company, but it only accept email attachment.
Thanks
I know how to send an email using PHP :
$to = $_POST['to'];
$from = 'From: '.$_POST['from'];
$subject = '['.$_POST['tag'].'] '.$_POST['subject'];
$message = $_POST['message'];
mail($to, $subject, $message, $from);
My question is, how can I attach a TEXT file ? Suppose I have a text file called "order.txt" and I want to attach it in the mail.
I need this to send the order to a company, but it only accept email attachment.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A rough guide to using phpmailer if you need it: http:Q_21141127.html#12148132
Your question made me curious because I use the mail function a lot but never thought/needed of doing it.
Anyway, found this, have a look:
http://www.sitepoint.com/article/advanced-email-php/5
Anyway, found this, have a look:
http://www.sitepoint.com/article/advanced-email-php/5
Really not worth going through it just to send an attachment, using a class will cut out all the work for you and allow you to easily add one or more attachments just by adding a line to the file. The advanced error checking and other features provided also make using a class such as phpmailer much more worthwhile.
Diablo84:
It's funny, because when I started to write my reply there was still no answer
When I finished writing it I saw your answer, had a look and realised just that ;)
It's funny, because when I started to write my reply there was still no answer
When I finished writing it I saw your answer, had a look and realised just that ;)