2 Replies Latest reply on Feb 25, 2008 11:56 AM by Media Post

    PANIC~  Email form not sending at all

    Media Post
      Hello,
      I have another post in for a radio button variable script, but right now I can't even get the simple mail form to work. I had it working and now it's not, so if anyone can help, I'd GREATLY appreciate it! Also, I need this to work for Flash 6. Below are my scripts:

      Flash frame 1:
      function sendmail(){
      infoToSend = new LoadVars();
      // create a loadvars object to hold the info to be sent.
      serverResponse = new LoadVars();
      // a separate instance for the reply
      infoToSend.name = nameField.text;
      infoToSend.email = emailField.text;
      //infoToSend.country = a3.text;
      infoToSend.message = messageField.text;
      //infoToSend.subject = "form from site";
      //infoToSend.recipient = "christy@mediapostinc.com";
      // this function will deal with the server response...
      serverResponse.onLoad = function(success:Boolean) {
      if (success) {
      // do something
      gotoAndStop("success");
      } else {
      // do something else
      }
      };
      // send the data
      infoToSend.sendAndLoad("sendmail.php", serverResponse, "POST");
      };
      stop();


      PHP code:
      <?php
      $MyEmail = 'christy@mediapostinc.com';
      $Subject = 'Flash Form';
      $FromEmail = $_POST['email'] ;
      $SuccessPage = 'thanks.php';
      $ErrorPage = 'interested.php';

      $name = $_POST['name'] ;
      $email = $_POST['email'] ;
      $message = $_POST['message'] ;

      $Message = '';

      $Message .= FixToShowString($_POST, 'name', 'Name');
      $Message .= FixToShowString($_POST, 'email', 'Email');
      $Message .= FixToShowString($_POST, 'message', 'Here are my comments');


      //$Message .= FixToShowString($_POST, 'message', 'Message');


      if (!empty($Message))
      {
      $Message = str_replace("\n.", "\n..", $Message);

      ini_set('SMTP', 'mail.mediapostinc.com');
      ini_set('smtp_port', '25');
      ini_set('sendmail_from', '.$FromEmail');

      $Headers = 'MIME-Version: 1.0' . "\r\n";
      $Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      $Headers .= 'From: '.$FromEmail ;

      mail($MyEmail, $Subject, $Message, $Headers);

      header('Location: '.$SuccessPage);
      die();
      }
      else
      {
      header('Location: '.$ErrorPage);
      die();
      }

      function FixToShowString($Array, $Key, $Title = false)
      {
      if (isset($Array[$Key]))
      {
      $String = trim($Array[$Key]);
      $String = strip_tags($String);

      if ('' != $String)
      {
      return (false === $Title ? $Key : $Title).": ".$String."\r\n<br /><br />";
      }
      }

      return;
      }

      function dump($arr)
      {
      echo '<pre>';
      print_r($arr);
      echo '</pre>';
      }

      die();


      ?>