+ Reply to Thread
Results 1 to 8 of 8

Thread: 2 email addresses from 1 simple php form ??
      
   

  1. #1
    john237 is offline Corporal
    Join Date
    Jun 2006
    Posts
    15

    Default 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. #2
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default 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

  3. #3
    john237 is offline Corporal
    Join Date
    Jun 2006
    Posts
    15

    Default 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

  4. #4
    Andy128's Avatar
    Andy128 is offline Major General
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,322

    Default 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!

  5. #5
    john237 is offline Corporal
    Join Date
    Jun 2006
    Posts
    15

    Default 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.

  6. #6
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,313

    Default 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");
    ?>

  7. #7
    Andy128's Avatar
    Andy128 is offline Major General
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,322

    Default 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!

  8. #8
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default 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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49