NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP AND EMAIL

Ken Robinson kenrbnsn at rbnsn.com
Wed Dec 28 12:58:10 EST 2005


Quoting Saima Mazhar <salmaz2000 at gmail.com>:

> Hello,
>
> I am creating an order form in HTML on a Linux machine. I would like to
> fetch all or some of the fields from that form and put them in an email and
> send the email to anyone. How can I do that? Is there an email feature in
> PHP? If there is such a feature, then is it supported by all the versions of
> PHP and where can I find some examples of this?

There is the mail() function in PHP
<http://www.php.net/manual/en/function.mail.php>

This is a simple script to mail the contents of your form back to 
yourself would
be:

<?php
   $to = 'youremail at your.domain.com';
   $subject = 'Order form contents';
   $headers = 'From: orderform at your.domain.com';
   $body = print_r($_POST,true); // assumes that you are using the POST method
   mail($to, $subject, $body, $headers);
?>

I have no error checking in the script and I haven't checked it for syntax
errors.

Ken




More information about the talk mailing list