Heh, I have read the 'Horror stories' about Matt's scripts also 🙂
Anyway, this is a poor man's version of formmail made in PHP. Its not supposed to be 'Da Ultimate formmail-script'. I made it one day when I got bored to do the mail-crap all over again for our clients.
Field 'submit' is the only required field in your form that you must have.
Field 'email' is optional, but if you want to see the email sender in the From: in email, add it to form.
And change the $to variable to email you want the form to be sent to.
Save the script below to something like form.php(or whatever). In flash you just send the form to this file and it should work.
<?php
if ($_POST['submit']) {
if ($_POST['email'])
$from=$_POST['email'];
else
$from='John Doe < >';
$today=date ("l dS of F Y h:i:s A");
// where to send the email
$to='someone@somewhere.com';
// get form's names and values to $message(not including submit)
reset ($_POST);
$message="This message was sent from ".$_SERVER['HTTP_HOST']." on ".$today."\n\n";
while (list ($key, $val) = each ($_POST)) {
if (!strstr('submit',$key))
$message.="$key:\n$val\n\n";
}
sendmail($from,$to,'WWW-form submission',$message);
}
function sendmail($from,$to,$subject,$message) {
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From:".$from."\n";
mail($to,$subject,$message,$headers);
}
?>