i need help with my mail script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shror

    #1

    i need help with my mail script

    dear all,

    i have started learning php 2 weeks ago and i have wrote my first
    script for mail sender and the script takes all my data and move to
    the thanks page but the problem is that the mails never comes, so i
    need your help with me, and here is my script:

    mail.htm code:

    <form method="POST" action="mail.ph p" onSubmit="">
    <p>email <input type="text" name="email" size="20"></p>
    <p>subject <input type="text" name="subject"> </p>
    <p>message<text area rows="2" name="message" cols="20"></textarea></
    p>
    <p><input type="submit" value="Submit" name="B1"><inpu t type="reset"
    value="Reset" name="B2"></p>
    </form>


    mail.php code:

    <?php
    $email = $HTTP_POST_VARS['email'];
    $subject = $HTTP_POST_VARS['subject'];
    $msg = $HTTP_POST_VARS['message'];
    $from = "s7els7.com ";
    if (mail($email,$s ubject,$message ,$from)) {
    echo "<h4>Thank you for sending email</h4>";
    } else {
    echo "<h4>Can't send email to $mail</h4>";
    }
    ?>


    now please tell me whats wrong with this scripts as i am still trying
    to learn the php and i need an expert help.
    you can check my script working at www.s7els7.com/mail.htm

    thanks

    shror

  • Ken Robinson

    #2
    Re: i need help with my mail script

    "shror" <shahirwm@gmail .comwrote in news:1171898875 .188006.234860
    @p10g2000cwp.go oglegroups.com:
    dear all,
    >
    i have started learning php 2 weeks ago and i have wrote my first
    script for mail sender and the script takes all my data and move to
    the thanks page but the problem is that the mails never comes, so i
    need your help with me, and here is my script:
    >
    mail.htm code:
    >
    <form method="POST" action="mail.ph p" onSubmit="">
    You don't need the onSubmit attribute if there is nothing to do
    <p>email <input type="text" name="email" size="20"></p>
    <p>subject <input type="text" name="subject"> </p>
    <p>message<text area rows="2" name="message" cols="20"></textarea></
    p>
    <p><input type="submit" value="Submit" name="B1"><inpu t type="reset"
    value="Reset" name="B2"></p>
    </form>
    >
    >
    mail.php code:
    >
    <?php
    $email = $HTTP_POST_VARS['email'];
    $subject = $HTTP_POST_VARS['subject'];
    $msg = $HTTP_POST_VARS['message'];
    You want to use the $_POST superglobal array here not the old
    $HTTP_POST_VARS array.

    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $msg = $_POST['message'];

    $from = "s7els7.com ";
    The "From" header needs to be formated correctly:
    "From: valid@emai.addr ess.here";

    $from = "From: youremailaddres @s7els7.com";
    if (mail($email,$s ubject,$message ,$from)) {
    echo "<h4>Thank you for sending email</h4>";
    } else {
    echo "<h4>Can't send email to $mail</h4>";
    }
    ?>
    Leaving your script like this, you are opening yourself up to spammers
    finding your form and using it to do all sorts of spamming.

    You should read this
    <http://www.nyphp.org/phundamentals/email_header_in jection.phparti cle
    on preventing Email Header Injection Exploits.

    Ken

    Comment

    • shror

      #3
      Re: i need help with my mail script

      Hi Ken,
      First of all i'd like to thank you so much for offering me help

      then about the onsubmit i have removed it now

      and in the mail.php page i have made some changes as you told me
      the new code is:

      <?php
      $email = $_POST['email'];
      $subject = $_POST['subject'];
      $message = $_POST['message'];
      $from = "From: email@s7els7.co m";
      $t = "shahirwm";
      $o = "@gmail.com ";
      $to = $t . $o;
      if (mail($email,$s ubject,$message ,$from,$to)) {
      echo "<h4>Thank you $email for sending $to this email</h4>";
      } else {
      echo "<h4>Can't send email to $email</h4>";
      }
      ?>


      i have made the $from as you said and almost every thing but still i
      cant get any mails from this script so please help me once more how to
      fix it and where is my problem.


      thanks once more for your help
      the form URL is: www.s7els7.com/mail.htm

      Comment

      • Klarth

        #4
        Re: i need help with my mail script

        I think there is a mistake in your arguments. From the manual, the
        order is:

        bool mail ( string $to, string $subject, string $message [, string
        $additional_hea ders [, string $additional_par ameters]] )

        Why do you pass $email as your first argument and $to as your last
        argument? I suggest trying mail($to,$subje ct,$message,$fr om) first.

        Another thing to check is your PHP mail configuration, if you are
        running your own server. The details are in the PHP manual:
        http://www.php.net/manual/en/ref.mail.php. But this applies if you are
        running PHP off your own computer.

        On Feb 20, 7:11 am, "shror" <shahi...@gmail .comwrote:
        Hi Ken,
        First of all i'd like to thank you so much for offering me help
        >
        then about the onsubmit i have removed it now
        >
        and in the mail.php page i have made some changes as you told me
        the new code is:
        >
        <?php
        $email = $_POST['email'];
        $subject = $_POST['subject'];
        $message = $_POST['message'];
        $from = "From: e...@s7els7.com ";
        $t = "shahirwm";
        $o = "@gmail.com ";
        $to = $t . $o;
        if (mail($email,$s ubject,$message ,$from,$to)) {
        echo "<h4>Thank you $email for sending $to this email</h4>";} else {
        >
        echo "<h4>Can't send email to $email</h4>";}
        >
        ?>
        >
        i have made the $from as you said and almost every thing but still i
        cant get any mails from this script so please help me once more how to
        fix it and where is my problem.
        >
        thanks once more for your help
        the form URL is:www.s7els7.com/mail.htm

        Comment

        • shror

          #5
          Re: i need help with my mail script

          On Feb 20, 6:11 am, "Klarth" <kah....@gmail. comwrote:
          I think there is a mistake in your arguments. From the manual, the
          order is:
          >
          bool mail ( string $to, string $subject, string $message [, string
          $additional_hea ders [, string $additional_par ameters]] )
          >
          Why do you pass $email as your first argument and $to as your last
          argument? I suggest trying mail($to,$subje ct,$message,$fr om) first.
          >
          Another thing to check is your PHP mail configuration, if you are
          running your own server. The details are in the PHP manual:http://www.php.net/manual/en/ref.mail.php. But this applies if you are
          running PHP off your own computer.
          >
          On Feb 20, 7:11 am, "shror" <shahi...@gmail .comwrote:
          >
          >
          >
          Hi Ken,
          First of all i'd like to thank you so much for offering me help
          >
          then about the onsubmit i have removed it now
          >
          and in the mail.php page i have made some changes as you told me
          the new code is:
          >
          <?php
          $email = $_POST['email'];
          $subject = $_POST['subject'];
          $message = $_POST['message'];
          $from = "From: e...@s7els7.com ";
          $t = "shahirwm";
          $o = "@gmail.com ";
          $to = $t . $o;
          if (mail($email,$s ubject,$message ,$from,$to)) {
          echo "<h4>Thank you $email for sending $to this email</h4>";} else {
          >
          echo "<h4>Can't send email to $email</h4>";}
          >
          ?>
          >
          i have made the $from as you said and almost every thing but still i
          cant get any mails from this script so please help me once more how to
          fix it and where is my problem.
          >
          thanks once more for your help
          the form URL is:www.s7els7.com/mail.htm- Hide quoted text -
          >
          - Show quoted text -
          Thank you Klarth for your note, it was correct and it fixed my form,
          now its working fine, but i just need one more thing which is how i
          set the X-mailer to be someting i do configer, is it possible or not
          thanks so much for your help once more and for the help of every body.

          shror

          Comment

          Working...