Fun With PHP

Fun With PHP

This may be obvious to some, but it's the first time I ever did this...

If you have access to a web host that allows PHP, you can use Creator to post to a PHP page and send an email.

Here's an example of the Creator post script: (the input.message is the rich-text field)
  1. MAIL_DATA={ "to_email" : input.to_email, "from_email" : input.from_email, "subject" : input.subject_field, "message" : input.message };
  2. RES = postUrl("http://my.site.org/index.php",MAIL_DATA);
  3. alert RES;
And here's my php form: Note how the Key:Value pairs in the map above match to the form below
  1. <html>
  2. <body>
  3. <?php
  4.   {
  5.   $to_email = $_REQUEST['to_email'] ;
  6.   $from_email = $_REQUEST['from_email'] ;
  7.   $subject = $_REQUEST['subject'] ;
  8.   $message = $_REQUEST['message'] ;
  9.   $headers = "From: ".$from_email."\r\n";
  10. $headers .= "Reply-To: ".$from_email."\r\n";
  11. $headers .= "Return-Path: ".$from_email."\r\n";
  12. $headers .= "Content-type: text/html\r\n"; 
  13.   mail($to_email, $subject, $message, $headers);
  14.   echo "email sent";
  15.   }
  16. ?>
  17. </body>
  18. </html>
This will send a rich text email with the alert RES = "email sent"

How cool is that? Well, I think it is...

John M. Whitney
Zen Office for Humans Online