Problem Getting Mail Function to Work

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

    Problem Getting Mail Function to Work

    Hello all,

    I am using a script to try to send an email from a we form. The
    script is as follows:

    <?php

    $name = $HTTP_POST_VARS['name'];
    $email = $HTTP_POST_VARS['email'];
    $phone = $HTTP_POST_VARS['phone'];
    $message = $HTTP_POST_VARS['message'];

    $name = stripslashes($n ame);
    $email = stripslashes($e mail);
    $phone = stripslashes($p hone);
    $message = stripslashes($m essage);

    $rec_email = "c@precisionimp ortrepair.net";
    $subject = "Web Page Contact Form";

    $msg_body .= "Name: $name\n";
    $msg_body .= "Phone Number: $phone\n";
    $msg_body .= "E-Mail: $email\n";
    $msg_body .= "Message: $message\n";
    $msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯\n";

    $header_info = "From: ".$name." <".$email.">" ;

    mail($rec_email , $subject, $msg_body, $header_info);

    ?>

    I have confirmed the email account exists, and I can send email to it
    outside of the script, but the script does not send the email. Any
    idea on what could be the issue? I have used this script on other
    websites with out a problem, the only thing I can think of is maye the
    domain name is so long, and if that is it, is there anyway around it?

    Thanks,
    Chris
  • Erwin Moller

    #2
    Re: Problem Getting Mail Function to Work

    Ice9Sysop@gmail .com schreef:
    Hello all,
    >
    Hi,

    Your script is sloppy and unclear on many point.
    I am using a script to try to send an email from a we form. The
    script is as follows:
    >
    <?php
    >
    $name = $HTTP_POST_VARS['name'];
    $email = $HTTP_POST_VARS['email'];
    $phone = $HTTP_POST_VARS['phone'];
    $message = $HTTP_POST_VARS['message'];

    $HTTP_POST_VARS is ancient.
    Use $_POST[] superglobal instead.
    >
    $name = stripslashes($n ame);
    $email = stripslashes($e mail);
    $phone = stripslashes($p hone);
    $message = stripslashes($m essage);
    You use stripslashes. That means you are SURE the slashes are added?
    In your php.ini you have magic_quotes_gp c set on, right?
    Otherwise you don't want to use stripslashes.
    >
    $rec_email = "c@precisionimp ortrepair.net";
    $subject = "Web Page Contact Form";
    >
    $msg_body .= "Name: $name\n";
    How can you add something to a variable that is not initialized?
    $msg_body .= "whatever";
    means:
    $msg_body = $msg_body."what ever";
    and since $msg_body is not set that would give you a warning (or notice,
    I am not sure).

    Be sure you have errorreporting on (E_ALL) and display errors during
    development.
    $msg_body .= "Phone Number: $phone\n";
    $msg_body .= "E-Mail: $email\n";
    $msg_body .= "Message: $message\n";
    $msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯\n";
    >
    $header_info = "From: ".$name." <".$email.">" ;
    >
    debug here, simply echo all variables you use, eg:
    echo "\$rec_email=$r ec_email<br>";
    echo "\$subject=$sub ject<br>";
    etc.
    mail($rec_email , $subject, $msg_body, $header_info);
    >
    ?>
    >
    I have confirmed the email account exists, and I can send email to it
    outside of the script, but the script does not send the email. Any
    idea on what could be the issue? I have used this script on other
    websites with out a problem, the only thing I can think of is maye the
    domain name is so long, and if that is it, is there anyway around it?
    Domainname is not a problem.
    Activate errorreporting, and see what you can find.
    >
    Thanks,
    Chris

    Succes.

    Regards,
    Erwin Moller

    Comment

    • The Hajj

      #3
      Re: Problem Getting Mail Function to Work

      On Jun 5, 12:14 am, Ice9Sy...@gmail .com wrote:
      Hello all,
      >
      I am using a script to try to send an email from a we form. The
      script is as follows:
      >
      <?php
      >
      $name = $HTTP_POST_VARS['name'];
      $email = $HTTP_POST_VARS['email'];
      $phone = $HTTP_POST_VARS['phone'];
      $message = $HTTP_POST_VARS['message'];
      >
      $name = stripslashes($n ame);
      $email = stripslashes($e mail);
      $phone = stripslashes($p hone);
      $message = stripslashes($m essage);
      >
      $rec_email = "c...@precision importrepair.ne t";
      $subject = "Web Page Contact Form";
      >
      $msg_body .= "Name: $name\n";
      $msg_body .= "Phone Number: $phone\n";
      $msg_body .= "E-Mail: $email\n";
      $msg_body .= "Message: $message\n";
      $msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯\n";
      >
      $header_info = "From: ".$name." <".$email.">" ;
      >
      mail($rec_email , $subject, $msg_body, $header_info);
      >
      ?>
      >
      I have confirmed the email account exists, and I can send email to it
      outside of the script, but the script does not send the email. Any
      idea on what could be the issue? I have used this script on other
      websites with out a problem, the only thing I can think of is maye the
      domain name is so long, and if that is it, is there anyway around it?
      >
      Thanks,
      Chris
      I'd add

      if (!mail($rec_ema il, $subject, $msg_body, $header_info)) {
      echo "You fail!!!";
      }

      Comment

      Working...