recommendation for a good mail form?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    recommendation for a good mail form?

    Hello,
    Can anyone recommend a simple PHP script for taking the contents of
    a form and emailing it to an address defined within the PHP script? I
    have downloaded a couple via Google, but they're not quite what I'm
    looking for.

    Thanks for your advice, - Dave

  • Erwin Moller

    #2
    Re: recommendation for a good mail form?

    laredotornado@z ipmail.com wrote:
    [color=blue]
    > Hello,
    > Can anyone recommend a simple PHP script for taking the contents of
    > a form and emailing it to an address defined within the PHP script? I
    > have downloaded a couple via Google, but they're not quite what I'm
    > looking for.
    >
    > Thanks for your advice, - Dave[/color]

    Hi Dave,

    Just use the buildin function mail() in PHP.
    And use $_POST["somevar"] to read the postingsvars.

    CHeck www.php.net for details on mail().

    Regards,
    Erwin Moller

    Comment

    • DH

      #3
      Re: recommendation for a good mail form?

      laredotornado@z ipmail.com wrote:[color=blue]
      > Hello,
      > Can anyone recommend a simple PHP script for taking the contents of
      > a form and emailing it to an address defined within the PHP script? I
      > have downloaded a couple via Google, but they're not quite what I'm
      > looking for.
      >
      > Thanks for your advice, - Dave[/color]

      IMHO, the following works well as an "include file" for various Contact
      Us forms on my client's web sites.

      function valid_email($em ail)
      {
      if(empty($email )){

      return false;


      }elseif(eregi(" ^[0-9a-z]([-_.+]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,7}$",
      $email)){

      return true;

      }

      return false;
      };

      $opts['admin_email'] = 'admin@domain.c om';

      $opts['admin_name'] = 'Some One';

      $opts['owner_email'] = 'owner@domain.c om';

      $msg = '';

      // Disallow certain HTML INPUT names from appearin in email messages

      $omit_field_nam e_array = array('s', 'submit');

      if(!isset($subj )){

      $subj = str_replace('ww w.', '', $_SERVER['HTTP_HOST']).' web site
      feedback';

      }

      while(list($key , $val) = each($_POST)){

      if($val != '' && !in_array($key, $omit_field_nam e_array)){

      $new_key = str_replace('_' , ' ', $key);

      $msg .= ucwords($new_ke y).':
      '.stripslashes( trim(strip_tags ($val)))."\n\n" ;

      }

      $$key = stripslashes(tr im(strip_tags($ val)));

      # Debug
      # echo "\n".$key.' = '.$val.'<br>';
      # exit;

      }

      $lf = isset($_SERVER["COMSPEC"])
      && stristr($_SERVE R["COMSPEC"], 'windows')
      ? "\r\n" : "\n";

      if($msg != ''){

      $msg .= 'Submitted: '.date('r')."\n ";

      if(valid_email( $email)){

      $hdr = 'From: <'.$email.'>'." $lf"
      .'Reply-To: '.$email."$lf"
      .'Return-Path: '.$email."$lf"
      .'X-Mailer: PHP '.phpversion(). "$lf"
      .'X-Priority: 3'."$lf"
      .'X-Sender: '.$email;
      }else{

      $hdr = 'From: "'.$opts['admin_name'].'"
      <'.$opts['admin_email'].'>'."$lf"
      .'Reply-To: '.$opts['admin_email']."$lf"
      .'Return-Path: '.$opts['admin_email']."$lf"
      .'X-Mailer: PHP '.phpversion(). "$lf"
      .'X-Priority: 3'."$lf"
      .'X-Sender: '.$opts['admin_email'];

      }

      $msg .= "{$lf}--{$lf}{$opts['admin_name']}{$lf}Site
      Administrator{$ lf}{$opts['admin_email']}";

      $opts['owner_email'] != $opts['admin_email'] ? $hdr .= "{$lf}BCC:
      {$opts['admin_email']}" : '';

      $sent = @mail($opts['owner_email'], $subj, $msg, $hdr);

      if(!($res = @mysql_query(sp rintf("INSERT INTO feedback (name, email,
      subj, comments)
      VALUES ('%s', '%s', '%s', '%s')",
      addslashes($nam e),
      $email, addslashes($sub j),
      addslashes($msg ))))){

      $opts['admin_msg'] = $_SERVER['PHP_SELF'].' did not insert
      feedback on '.$_SERVER['HTTP_HOST'];

      }

      }


      Comment

      Working...