Announcement

Collapse
No announcement yet.

2 email addresses from 1 simple php form ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2 email addresses from 1 simple php form ??

    Can a simple php email form be directed
    to 2 email addresses and if yes, what would the line
    of code be ?

    thanks for any help in advance

  • #2
    Re: 2 email addresses from 1 simple php form ??

    You would need to duplicate and edit the mail(); part. If you post the script you have ill reply with the changes you need to have it send to 2 different emails

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment


    • #3
      Re: 2 email addresses from 1 simple php form ??

      here is the snippet from the script

      //Sending Email to form owner
      $mailto = "xxxxx@yyyyyy.com";
      $mailsubj = "Feedback from website form";
      $mailhead = "From: $email\n";
      reset ($HTTP_POST_VARS);
      $mailbody = "Values submitted from web site form:\n";
      while (list ($key, $val) = each ($HTTP_POST_VARS))
      {
      $mailbody .= "$key : $val\n";
      }
      mail($mailto, $mailsubj, $mailbody, $mailhead);
      header("Location: confirm.html");
      ?>

      much appreciate

      Comment


      • #4
        Re: 2 email addresses from 1 simple php form ??

        I believe the below would work;

        //Sending Email to form owner
        $mailto = "xxxxx@yyyyyy.com , bbbb@bbbb.com";
        $mailsubj = "Feedback from website form";
        $mailhead = "From: $email\n";
        reset ($HTTP_POST_VARS);
        $mailbody = "Values submitted from web site form:\n";
        while (list ($key, $val) = each ($HTTP_POST_VARS))
        {
        $mailbody .= "$key : $val\n";
        }
        mail($mailto, $mailsubj, $mailbody, $mailhead);
        header("Location: confirm.html");
        ?>


        Andy
        PHP- is a blast!

        Comment


        • #5
          Re: 2 email addresses from 1 simple php form ??

          andy128, This does send 2 emails but only to the first of the 2 addresses
          like so: xxxxx@yyyyyy.com , bbbb@bbbb.com
          the from field contains: xxxxx@yyyyyy.com , bbbb@bbbb.com
          in both emails received.

          What I would like is for a single email to be sent to 2 different addresses.

          Comment


          • #6
            Re: 2 email addresses from 1 simple php form ??

            Try this, its a little bit longer but it does what you want..

            /Sending Email to form owner
            $mailto = "xxxxx@yyyyyy.com";
            $mailsubj = "Feedback from website form";
            $mailhead = "From: $email\n";
            reset ($HTTP_POST_VARS);
            $mailbody = "Values submitted from web site form:\n";
            while (list ($key, $val) = each ($HTTP_POST_VARS))
            {
            $mailbody .= "$key : $val\n";
            }
            mail($mailto, $mailsubj, $mailbody, $mailhead);
            /Sending Email to form owner
            $mailto = "aaaaaa@bbbbbbb.com";
            $mailsubj = "Feedback from website form";
            $mailhead = "From: $email\n";
            reset ($HTTP_POST_VARS);
            $mailbody = "Values submitted from web site form:\n";
            while (list ($key, $val) = each ($HTTP_POST_VARS))
            {
            $mailbody .= "$key : $val\n";
            }
            mail($mailto, $mailsubj, $mailbody, $mailhead);
            header("Location: confirm.html");
            ?>
            Have fun
            Regards..... David

            Step by Step Visual Tutorials for the complete beginner
            Newbies / Beginners Forum
            FREE Membership Login Scripts: - Meta Tags Analyzer
            My Social Networking Site - Free Contact Forms
            Finished your New website!! Now get it noticed Here:

            Comment


            • #7
              Re: 2 email addresses from 1 simple php form ??

              John-
              I am confused. It should not do as you are saying. I will experiment with it in the am and get back to you.

              Please post the script you used so I have someting to use as an example in my test.

              Andy
              PHP- is a blast!

              Comment


              • #8
                Re: 2 email addresses from 1 simple php form ??

                I beleive its because of the comma placement

                Try this

                //Sending Email to form owner
                $mailto = "xxxxx@yyyyyy.com, bbbb@bbbb.com";
                $mailsubj = "Feedback from website form";
                $mailhead = "From: $email\n";
                reset ($HTTP_POST_VARS);
                $mailbody = "Values submitted from web site form:\n";
                while (list ($key, $val) = each ($HTTP_POST_VARS))
                {
                $mailbody .= "$key : $val\n";
                }
                mail($mailto, $mailsubj, $mailbody, $mailhead);
                header("Location: confirm.html");
                ?>

                If that doesnt work do this:

                //Sending Email to form owner
                $mailto_1 = "xxxxx@yyyyyy.com";
                $mailto_2 = "qqqqqq@wwwww.com";
                $mailsubj = "Feedback from website form";
                $mailhead = "From: $email\n";
                reset ($HTTP_POST_VARS);
                $mailbody = "Values submitted from web site form:\n";
                while (list ($key, $val) = each ($HTTP_POST_VARS))
                {
                $mailbody .= "$key : $val\n";
                }
                mail($mailto_1, $mailsubj, $mailbody, $mailhead);
                mail($mailto_2, $mailsubj, $mailbody, $mailhead);
                header("Location: confirm.html");
                ?>

                If neither work, then... im not sure, perhaps the way the email is formated

                Register/Login Script
                Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                Comment

                Working...
                X