Until now we have been collecting data from the user and displaying it back to the user in the form of a web page. Suppose you wish the contents of the form to be mailed either to yourself or the user.
We can create a simple script that sends a simple email to an address typed in by the user.
Unlike the other scripts, this emails data to an address supplied by the person filling in the form. If this script was runnable here, it would allow anyone to email anyone else, with the web server as a return address. This is why a working version is not on this tutorial. You need to save the above code to your public_html directory and run it from there. That way, the return address will be set as the owner of the script (you).
sendmail or mail?
One other thing to note is the use of 'sendmail' rather than 'mail'. It is important to use 'sendmail' since this talks directly to the mail server. The path on your server (EziHosting Clients) to this is:
/usr/sbin/sendmail -t
The -t flag is necessary as it causes the sendmail program to read message for recipients.
To:, Cc:, and Bcc: lines will be scanned for people to send to. (The Bcc: line will be deleted before transmission.)
Don't forget the blank line between the email headers and the start of the message.
We hope this tutorial was helpful. If you like, you can link to our tutorials from your web site. Just use the following code:
<a href="http://www.ezi-hosting.com/tutorials.htm">Free Scripting Tutorials from EziHosting</a>






