Help with mail script

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

    Help with mail script




    Hi,
    I use the script below to send a email from a contact form but it would be
    nice if the conformed sent page showed what was sent.Question how can I do
    this ?

    Thanks
    Chris

    <?php
    $mailto = 'email@mail.co' ;
    $subject = "Feedback Form" ;
    $formurl = "http://page.co/ of form" ;
    $errorurl = "http://page.co/contact.php" ;
    $thankyouurl = "http://page.co/thankyou.php" ;
    $uself = 1;
    $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $comments = $_POST['comments'] ;
    $http_referrer = getenv( "HTTP_REFER ER" );

    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit ;
    }
    if (empty($name) || empty($email) || empty($comments )) {
    header( "Location: $errorurl" );
    exit ;
    }
    if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
    header( "Location: $errorurl" );
    exit ;
    }

    if (get_magic_quot es_gpc()) {
    $comments = stripslashes( $comments );
    }

    if (!strstr($_SERV ER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
    referrer");

    }

    $messageproper =

    "This message was sent from:\n" .
    "$http_referrer \n" .
    "------------------------------------------------------------\n" .
    "Name of sender: $name\n" .
    "Email of sender: $email\n" .
    "------------------------- COMMENTS -------------------------\n\n" .
    $comments .
    "\n\n------------------------------------------------------------\n" ;

    mail($mailto, $subject, $messageproper,
    "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
    $headersep . "X-Mailer: Feed Back" );
    header( "Location: $thankyouurl" );
    exit ;

    ?>


  • Erwin Moller

    #2
    Re: Help with mail script

    Joker7 schreef:
    Hi,
    I use the script below to send a email from a contact form but it would be
    nice if the conformed sent page showed what was sent.Question how can I do
    this ?
    >
    Thanks
    Chris
    >
    <?php
    $mailto = 'email@mail.co' ;
    $subject = "Feedback Form" ;
    $formurl = "http://page.co/ of form" ;
    $errorurl = "http://page.co/contact.php" ;
    $thankyouurl = "http://page.co/thankyou.php" ;
    $uself = 1;
    $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $comments = $_POST['comments'] ;
    $http_referrer = getenv( "HTTP_REFER ER" );
    >
    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit ;
    }
    if (empty($name) || empty($email) || empty($comments )) {
    header( "Location: $errorurl" );
    exit ;
    }
    if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
    header( "Location: $errorurl" );
    exit ;
    }
    >
    if (get_magic_quot es_gpc()) {
    $comments = stripslashes( $comments );
    }
    >
    if (!strstr($_SERV ER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
    referrer");
    >
    }
    >
    $messageproper =
    >
    "This message was sent from:\n" .
    "$http_referrer \n" .
    "------------------------------------------------------------\n" .
    "Name of sender: $name\n" .
    "Email of sender: $email\n" .
    "------------------------- COMMENTS -------------------------\n\n" .
    $comments .
    "\n\n------------------------------------------------------------\n" ;
    >
    mail($mailto, $subject, $messageproper,
    "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
    $headersep . "X-Mailer: Feed Back" );
    header( "Location: $thankyouurl" );
    exit ;
    >
    ?>
    >
    >
    Hi,



    says for returnvalue of your mail command:
    Return Values
    Returns TRUE if the mail was successfully accepted for delivery, FALSE
    otherwise.
    It is important to note that just because the mail was accepted for
    delivery, it does NOT mean the mail will actually reach the intended
    destination.
    So just change it in:
    $mailresult = mail(..yourstuf fhere..);

    And then use the value for $mailresult to display if the sending was
    succesful.

    echo (($mailresult) ? "SUCCES!":"PROB LEM WITH SENDING" );

    Regards,
    Erwin Moller

    Comment

    • Tim McGurk

      #3
      Re: Help with mail script

      The easiest way is to put it in a session variable and just echo the
      session variable on the confirmation page...

      //// on the form page, before the redirect
      $_SESSION['sentmessage']=$messageproper ;

      ///// on the confirmation page
      $OutPut=str_rep lace("\n","<br> ",$_SESSION['sentmessage']);
      echo($OutPut);





      "Joker7" wrote in message news:<7FATj.212 4$pI4.33@fe101. usenetserver.co m>...
      >
      >
      >
      Hi,
      I use the script below to send a email from a contact form but it would be
      nice if the conformed sent page showed what was sent.Question how can I do
      this ?
      >
      Thanks
      Chris
      >
      $mailto = 'email@mail.co' ;
      $subject = "Feedback Form" ;
      $formurl = "http://page.co/ of form" ;
      $errorurl = "http://page.co/contact.php" ;
      $thankyouurl = "http://page.co/thankyou.php" ;
      $uself = 1;
      $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
      $name = $_POST['name'] ;
      $email = $_POST['email'] ;
      $comments = $_POST['comments'] ;
      $http_referrer = getenv( "HTTP_REFER ER" );
      >
      if (!isset($_POST['email'])) {
      header( "Location: $formurl" );
      exit ;
      }
      if (empty($name) || empty($email) || empty($comments )) {
      header( "Location: $errorurl" );
      exit ;
      }
      if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
      header( "Location: $errorurl" );
      exit ;
      }
      >
      if (get_magic_quot es_gpc()) {
      $comments = stripslashes( $comments );
      }
      >
      if (!strstr($_SERV ER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
      referrer");
      >
      }
      >
      $messageproper =
      >
      "This message was sent from:\n" .
      "$http_referrer \n" .
      "------------------------------------------------------------\n" .
      "Name of sender: $name\n" .
      "Email of sender: $email\n" .
      "------------------------- COMMENTS -------------------------\n\n" .
      $comments .
      "\n\n------------------------------------------------------------\n" ;
      >
      mail($mailto, $subject, $messageproper,
      "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
      $headersep . "X-Mailer: Feed Back" );
      header( "Location: $thankyouurl" );
      exit ;
      >
      ?>
      >
      >


      Comment

      • Jerry Stuckle

        #4
        Re: Help with mail script

        Tim McGurk wrote:
        The easiest way is to put it in a session variable and just echo the
        session variable on the confirmation page...
        >
        //// on the form page, before the redirect
        $_SESSION['sentmessage']=$messageproper ;
        >
        ///// on the confirmation page
        $OutPut=str_rep lace("\n","<br> ",$_SESSION['sentmessage']);
        echo($OutPut);
        >
        >
        >
        >
        >
        "Joker7" wrote in message news:<7FATj.212 4$pI4.33@fe101. usenetserver.co m>...
        >>
        >>
        >Hi,
        >I use the script below to send a email from a contact form but it would be
        >nice if the conformed sent page showed what was sent.Question how can I do
        >this ?
        >>
        >Thanks
        >Chris
        >>
        >>$mailto = 'email@mail.co' ;
        >$subject = "Feedback Form" ;
        >$formurl = "http://page.co/ of form" ;
        >$errorurl = "http://page.co/contact.php" ;
        >$thankyouurl = "http://page.co/thankyou.php" ;
        >$uself = 1;
        >$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
        >$name = $_POST['name'] ;
        >$email = $_POST['email'] ;
        >$comments = $_POST['comments'] ;
        >$http_referr er = getenv( "HTTP_REFER ER" );
        >>
        >if (!isset($_POST['email'])) {
        >header( "Location: $formurl" );
        >exit ;
        >}
        >if (empty($name) || empty($email) || empty($comments )) {
        >header( "Location: $errorurl" );
        >exit ;
        >}
        >if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
        >header( "Location: $errorurl" );
        >exit ;
        >}
        >>
        >if (get_magic_quot es_gpc()) {
        >$comments = stripslashes( $comments );
        >}
        >>
        >if (!strstr($_SERV ER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
        >referrer");
        >>
        >}
        >>
        >$messageprop er =
        >>
        >"This message was sent from:\n" .
        >"$http_referre r\n" .
        >"------------------------------------------------------------\n" .
        >"Name of sender: $name\n" .
        >"Email of sender: $email\n" .
        >"------------------------- COMMENTS -------------------------\n\n" .
        >$comments .
        >"\n\n------------------------------------------------------------\n" ;
        >>
        >mail($mailto , $subject, $messageproper,
        >"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
        >$headersep . "X-Mailer: Feed Back" );
        >header( "Location: $thankyouurl" );
        >exit ;
        >>
        >?>
        >>
        >>
        >
        >
        >
        >
        Please learn to reply to the original message, instead of starting a new
        thread.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Tim McGurk

          #5
          Re: Help with mail script

          I did reply; I didn't start a new thread. The original message is an old
          one, but he hadn't gotten an answer. Load the messages from May or
          thereabouts, and the original message will appear in the list rather than my
          reply.

          But thanks for the concern!

          "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
          news:g61qhg$f50 $1@registered.m otzarella.org.. .
          Tim McGurk wrote:
          > The easiest way is to put it in a session variable and just echo the
          >session variable on the confirmation page...
          >>
          >//// on the form page, before the redirect
          >$_SESSION['sentmessage']=$messageproper ;
          >>
          >///// on the confirmation page
          >$OutPut=str_re place("\n","<br >",$_SESSION['sentmessage']);
          >echo($OutPut );
          >>
          >>
          >>
          >>
          >>
          >"Joker7" wrote in message
          >news:<7FATj.21 24$pI4.33@fe101 .usenetserver.c om>...
          >>>
          >>>
          >>Hi,
          >>I use the script below to send a email from a contact form but it would
          >>be
          >>nice if the conformed sent page showed what was sent.Question how can I
          >>do
          >>this ?
          >>>
          >>Thanks
          >>Chris
          >>>
          >>>$mailto = 'email@mail.co' ;
          >>$subject = "Feedback Form" ;
          >>$formurl = "http://page.co/ of form" ;
          >>$errorurl = "http://page.co/contact.php" ;
          >>$thankyouur l = "http://page.co/thankyou.php" ;
          >>$uself = 1;
          >>$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
          >>$name = $_POST['name'] ;
          >>$email = $_POST['email'] ;
          >>$comments = $_POST['comments'] ;
          >>$http_referre r = getenv( "HTTP_REFER ER" );
          >>>
          >>if (!isset($_POST['email'])) {
          >>header( "Location: $formurl" );
          >>exit ;
          >>}
          >>if (empty($name) || empty($email) || empty($comments )) {
          >>header( "Location: $errorurl" );
          >>exit ;
          >>}
          >>if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
          >>header( "Location: $errorurl" );
          >>exit ;
          >>}
          >>>
          >>if (get_magic_quot es_gpc()) {
          >>$comments = stripslashes( $comments );
          >>}
          >>>
          >>if (!strstr($_SERV ER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
          >>referrer");
          >>>
          >>}
          >>>
          >>$messageprope r =
          >>>
          >>"This message was sent from:\n" .
          >>"$http_referr er\n" .
          >>"------------------------------------------------------------\n" .
          >>"Name of sender: $name\n" .
          >>"Email of sender: $email\n" .
          >>"------------------------- COMMENTS -------------------------\n\n" .
          >>$comments .
          >>"\n\n------------------------------------------------------------\n" ;
          >>>
          >>mail($mailt o, $subject, $messageproper,
          >>"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>"
          >>.
          >>$headersep . "X-Mailer: Feed Back" );
          >>header( "Location: $thankyouurl" );
          >>exit ;
          >>>
          >>?>
          >>>
          >>>
          >>
          >>
          >>
          >>
          >
          Please learn to reply to the original message, instead of starting a new
          thread.
          >
          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===
          >

          Comment

          • Jerry Stuckle

            #6
            Re: Help with mail script

            Tim McGurk wrote:
            "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
            news:g61qhg$f50 $1@registered.m otzarella.org.. .
            >Tim McGurk wrote:
            >> The easiest way is to put it in a session variable and just echo the
            >>session variable on the confirmation page...
            >>>
            >>//// on the form page, before the redirect
            >>$_SESSION['sentmessage']=$messageproper ;
            >>>
            >>///// on the confirmation page
            >>$OutPut=str_r eplace("\n","<b r>",$_SESSION['sentmessage']);
            >>echo($OutPut) ;
            >>>
            >>>
            >>>
            >>>
            >>>
            >>"Joker7" wrote in message
            >>news:<7FATj.2 124$pI4.33@fe10 1.usenetserver. com>...
            >>>>
            >>>Hi,
            >>>I use the script below to send a email from a contact form but it would
            >>>be
            >>>nice if the conformed sent page showed what was sent.Question how can I
            >>>do
            >>>this ?
            >>>>
            >>>Thanks
            >>>Chris
            >>>>
            >>>>$mailto = 'email@mail.co' ;
            >>>$subject = "Feedback Form" ;
            >>>$formurl = "http://page.co/ of form" ;
            >>>$errorurl = "http://page.co/contact.php" ;
            >>>$thankyouu rl = "http://page.co/thankyou.php" ;
            >>>$uself = 1;
            >>>$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
            >>>$name = $_POST['name'] ;
            >>>$email = $_POST['email'] ;
            >>>$comments = $_POST['comments'] ;
            >>>$http_referr er = getenv( "HTTP_REFER ER" );
            >>>>
            >>>if (!isset($_POST['email'])) {
            >>>header( "Location: $formurl" );
            >>>exit ;
            >>>}
            >>>if (empty($name) || empty($email) || empty($comments )) {
            >>>header( "Location: $errorurl" );
            >>>exit ;
            >>>}
            >>>if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
            >>>header( "Location: $errorurl" );
            >>>exit ;
            >>>}
            >>>>
            >>>if (get_magic_quot es_gpc()) {
            >>>$comments = stripslashes( $comments );
            >>>}
            >>>>
            >>>if (!strstr($_SERV ER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
            >>>referrer") ;
            >>>>
            >>>}
            >>>>
            >>>$messageprop er =
            >>>>
            >>>"This message was sent from:\n" .
            >>>"$http_refer rer\n" .
            >>>"------------------------------------------------------------\n" .
            >>>"Name of sender: $name\n" .
            >>>"Email of sender: $email\n" .
            >>>"------------------------- COMMENTS -------------------------\n\n" .
            >>>$comments .
            >>>"\n\n------------------------------------------------------------\n" ;
            >>>>
            >>>mail($mailto , $subject, $messageproper,
            >>>"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>"
            >>>.
            >>>$headersep . "X-Mailer: Feed Back" );
            >>>header( "Location: $thankyouurl" );
            >>>exit ;
            >>>>
            >>>?>
            >>>>
            >>>>
            >>>
            >>>
            >>>
            >Please learn to reply to the original message, instead of starting a new
            >thread.
            >>
            >--
            >============== ====
            >Remove the "x" from my email address
            >Jerry Stuckle
            >JDS Computer Training Corp.
            >jstucklex@attgl obal.net
            >============== ====
            >>
            >
            >
            I did reply; I didn't start a new thread. The original message is an old
            one, but he hadn't gotten an answer. Load the messages from May or
            thereabouts, and the original message will appear in the list rather
            than my
            reply.
            >
            But thanks for the concern!
            >
            (Top posting fixed)

            Sorry - I checked two different news servers, and the original message
            wasn't on either one. I did check your headers, but didn't see the
            message you were supposedly referencing, either.

            Guess it was just too old for the servers. Sorry.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            Working...