I fussed around with setting up a "Contact Us" page in my site and came up with this PHP script, with the help of Essential PHP Tools (D. Sklar, apress books) and the PEAR Mail Extension from the PEAR Website. I used a form in the final version, but the basic mechanics are here:
<?php
require 'Mail.php'; \\ From the PEAR mail package
$mailer =& Mail::factory('sendmail'); \\ Create object using the sendmail driver
$to = 'addressee@wherever.com'; \\ Where to send it
$headers = array('From' => 'sendermailname@senderaddress.com',
'Subject' => 'Hungry?',
'Cc' => 'sendheretoo@anotheraddress.com');
/* The cc: does not work right ... yet */
/* Create a body of text */
$body=<<<_MSGx_
Are you hungry? Wouldn't you like a cold,
sweet ice cream cone?
Why not stop by your local
ice cream parlor today for a few
scoops of Guava Mint
Bouillon?
Sincerely,
Your local ice cream booster
_MSGx_;
$res = $mailer->send($to, $headers, $body); \\ the send() method does the work
// If the message can't be sent, send() returns a
// PEAR::Error object
if (PEAR::isError($res)) {
print "Couldn't send message: " . $res->getMessage();
}
?>