Using Formmail.php and trying to select multiple recipients

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

    Using Formmail.php and trying to select multiple recipients

    Hi! Total "newbie to programming" here.

    I'm using Jack's Formmail.php, code at:


    and I'm trying to figure out how I can have it send an identical message to
    more than one recipient, based on a checkbox selected by the user who
    submits the form.


    <input type="checkbox" name="email1" value="recipien t1" />Recipient 1
    <input type="checkbox" name="email2" value="recipien t2" />Recipient 2
    <input type="checkbox" name="email3" value="recipien t3" />Recipient 3

    where "recipient[n]" is stored in the script:

    "recipient1 " = "email1@email.c om"
    "recipient2 " = "email2@email.c om"
    "recipient3 " = "email3@email.c om"

    If the user checks recipient1 AND recipient3, it would send the message to
    both of the above e-mail addresses.

    Is there a script out there that could do this better?
    Any help you can give me would be very helpful!

    Thanks so much,
    Maggie




  • Geoff Berrow

    #2
    Re: Using Formmail.php and trying to select multiple recipients

    I noticed that Message-ID:
    <6hrje.2222$5Z1 .1980@newssvr30 .news.prodigy.c om> from Maggie Blue
    contained the following:
    [color=blue]
    ><input type="checkbox" name="email1" value="recipien t1" />Recipient 1
    ><input type="checkbox" name="email2" value="recipien t2" />Recipient 2
    ><input type="checkbox" name="email3" value="recipien t3" />Recipient 3
    >
    >where "recipient[n]" is stored in the script:
    >
    >"recipient1 " = "email1@email.c om"
    >"recipient2 " = "email2@email.c om"
    >"recipient3 " = "email3@email.c om"[/color]

    Give the checkboxes the same name
    <input type="checkbox" name="email[]" value="recipien t1" />Recipient 1
    <input type="checkbox" name="email[]" value="recipien t2" />Recipient 2
    <input type="checkbox" name="email[]" value="recipien t3" />Recipient 3

    then

    $mailto=implode (",",$_POST['email'] );


    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Daniel Tryba

      #3
      Re: Using Formmail.php and trying to select multiple recipients

      Geoff Berrow <blthecat@ckdog .co.uk> wrote:[color=blue][color=green]
      >><input type="checkbox" name="email1" value="recipien t1" />Recipient 1
      >><input type="checkbox" name="email2" value="recipien t2" />Recipient 2
      >><input type="checkbox" name="email3" value="recipien t3" />Recipient 3
      >>
      >>where "recipient[n]" is stored in the script:
      >>
      >>"recipient1 " = "email1@email.c om"
      >>"recipient2 " = "email2@email.c om"
      >>"recipient3 " = "email3@email.c om"[/color]
      >
      > Give the checkboxes the same name
      > <input type="checkbox" name="email[]" value="recipien t1" />Recipient 1
      > <input type="checkbox" name="email[]" value="recipien t2" />Recipient 2
      > <input type="checkbox" name="email[]" value="recipien t3" />Recipient 3
      >
      > then
      >
      > $mailto=implode (",",$_POST['email'] );[/color]

      Close but not complete since $_POST['email'] doesn't (and certainly
      shouldn't) contain the emailadresses.

      To compare the _values_ of $_POST['email'] with the _keys_ in
      $recipient:

      <input type="checkbox" name="email[]" value="0" />Recipient 0
      ....
      <input type="checkbox" name="email[]" value="N" />Recipient N

      $recipient[]="email1@exampl e.com"
      ....
      $recipient[]="emailn@exampl e.com"

      $mailto="";
      foreach(array_i ntersect(array_ keys($recipient ),array_values( $_POST['email']))
      as $val)
      {
      $mailto.=$recip ient[$val].',';
      }
      $mailto=trim($m ailto,',');

      Comment

      • Geoff Berrow

        #4
        Re: Using Formmail.php and trying to select multiple recipients

        I noticed that Message-ID: <428e8cca$0$954 38$c5fe704e@new s6.xs4all.nl>
        from Daniel Tryba contained the following:
        [color=blue][color=green]
        >> $mailto=implode (",",$_POST['email'] );[/color]
        >
        >Close but not complete since $_POST['email'] doesn't (and certainly
        >shouldn't) contain the emailadresses.[/color]


        It was late, I was in a hurry...and you have to leave some challenge for
        the OP. <g>
        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • Maggie Blue

          #5
          Re: Using Formmail.php and trying to select multiple recipients


          "Geoff Berrow" <blthecat@ckdog .co.uk> wrote in message
          news:t2ku81d7sj t1vipr86phmm7ei 3hn45inhu@4ax.c om...[color=blue]
          > I noticed that Message-ID: <428e8cca$0$954 38$c5fe704e@new s6.xs4all.nl>
          > from Daniel Tryba contained the following:
          >[color=green][color=darkred]
          > >> $mailto=implode (",",$_POST['email'] );[/color]
          > >
          > >Close but not complete since $_POST['email'] doesn't (and certainly
          > >shouldn't) contain the emailadresses.[/color]
          >
          >
          > It was late, I was in a hurry...and you have to leave some challenge for
          > the OP. <g>
          > --
          > Geoff Berrow (put thecat out to email)
          > It's only Usenet, no one dies.
          > My opinions, not the committee's, mine.
          > Simple RFDs http://www.ckdog.co.uk/rfdmaker/[/color]

          Ooo! How mean! Especially since the OP doesn't know how to read any of that
          stuff!
          Thanks, everyone; I'll try it out this morning.
          -- Maggie Blue


          Comment

          Working...