Using SendMail in Forms w/PHP HTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jcage@lycos.com

    Using SendMail in Forms w/PHP HTML

    Is there any tutorials online for sending email through forms? I can
    send an email as well as write to my MySQL database from home with the
    following code but not at work. I think there might be something I'm
    missing header-wise that keeps me from making this work on my work
    system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do
    though I'm using 5.x at home), and MySQL as the database. Thanks VERY
    much for any help or pointers to a good tutorial. I'm trying to
    provide an input form that writes to the database as well as emails
    the recipient letting them know there's been activity. Thanks, John

    My form PHP code is as follows:

    Input form 1:
    <html>
    <body>
    <form method="post" action="messagi ng2.php">
    <input type="hidden" name="id" value="NULL">
    <center>
    <table border="8">
    <tr>
    <td>Date:</td>
    <td align="left"><i nput type="text" name="date" size="14"
    maxlength="16" value="<? print strftime("%m/%d/%Y %H:%M"); ?>"></
    td>
    </tr>
    <tr>
    <td>Your Name:<font color=red>*</font></td><td align="left"><i nput
    type="text" name="name" size="14" maxlength="20" value=""></td>
    </tr>
    <tr>
    <td>Subject:<fo nt color=red>*</font></td><td align="left"><i nput
    type="text" name="subject" size="14" maxlength="20" value=""></td>
    </tr>
    <tr>
    <td>Message For:<font color=red>*</font></td>
    <td><select name="to" style='width: 110px;'>
    <option value = ""></option>
    <option value ="joe@lycos.com ">Joe</option>
    <option value ="randy@gmail.c om">Randy</option>
    </td>
    </tr>
    <tr>
    <td nowrap>
    Message:<font color=red>*</font></div>
    </td>
    <td>
    <textarea type="text" name="text" cols="35" rows="5"></textarea>
    </tr>
    </td>
    <tr>
    <td colspan="2" align="center"> <input type="submit" value="Enter"></
    td>
    </tr>
    </table>
    </form>
    </center><p>
    </body>
    </html>

    Input form 2:
    <html>
    <font color="#990099" size="+1"><span
    style="font-size:18"><p>
    <TABLE cellSpacing=0 cellPadding=10 width="95%"
    align=center border=8">
    <TBODY><TR><T D vAlign=top align=left><P>< FONT
    face=arial color=bright white><b>
    <?php
    require_once('g eneric_connect. php');
    $DBName = "messages";
    $table = "messages_t bl";

    $id = $_POST['id'];
    $date = $_POST['date'];
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $to = $_POST['to'];
    $text = $_POST['text'];

    mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect
    to database"); // make connection to database
    mysql_select_db ($DBName) or die("Unable to select database
    $DBName"); // select database
    $sqlquery = "INSERT INTO $table VALUES('$id', '$date', '$name',
    '$subject', '$to', '$text')";
    if ($results = mysql_query($sq lquery)) {

    $to = stripslashes($t o)."\r\n";
    $subject = stripslashes($s ubject);
    $text = stripslashes($t ext);
    mail($to, $subject, $text, "From: admin@work.com");
    }

    mysql_close();
    print "<center><t able border=\"0\" width=\"500\">< tr><td>";
    print "<p><font face=\"verdana\ " size=\"+0\">
    <center>You Just Entered This Information into the
    Database<p><blo ckquote>";
    print "Date: $date<p>Your Name: $name<p>Message For:$to<p>Subje ct:
    $subject<p>Mess age:$text</blockquote></td></tr></table>
    </CENTER>
    </html>";
    ?>

    </FONT></CENTER></b>
    </H3></TD></TR></TBODY></TABLE>
    </html><p>

    portion of php.ini file that deals with mail configuration:

    [mail function]
    ; For Win32 only.
    SMTP = mail.work.com
    smtp_port = 25

  • Jerry Stuckle

    #2
    Re: Using SendMail in Forms w/PHP HTML

    jcage@lycos.com wrote:
    Is there any tutorials online for sending email through forms? I can
    send an email as well as write to my MySQL database from home with the
    following code but not at work. I think there might be something I'm
    missing header-wise that keeps me from making this work on my work
    system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do
    though I'm using 5.x at home), and MySQL as the database. Thanks VERY
    much for any help or pointers to a good tutorial. I'm trying to
    provide an input form that writes to the database as well as emails
    the recipient letting them know there's been activity. Thanks, John
    >
    My form PHP code is as follows:
    >
    Input form 1:
    <html>
    <body>
    <form method="post" action="messagi ng2.php">
    <input type="hidden" name="id" value="NULL">
    <center>
    <table border="8">
    <tr>
    <td>Date:</td>
    <td align="left"><i nput type="text" name="date" size="14"
    maxlength="16" value="<? print strftime("%m/%d/%Y %H:%M"); ?>"></
    td>
    </tr>
    <tr>
    <td>Your Name:<font color=red>*</font></td><td align="left"><i nput
    type="text" name="name" size="14" maxlength="20" value=""></td>
    </tr>
    <tr>
    <td>Subject:<fo nt color=red>*</font></td><td align="left"><i nput
    type="text" name="subject" size="14" maxlength="20" value=""></td>
    </tr>
    <tr>
    <td>Message For:<font color=red>*</font></td>
    <td><select name="to" style='width: 110px;'>
    <option value = ""></option>
    <option value ="joe@lycos.com ">Joe</option>
    <option value ="randy@gmail.c om">Randy</option>
    </td>
    </tr>
    <tr>
    <td nowrap>
    Message:<font color=red>*</font></div>
    </td>
    <td>
    <textarea type="text" name="text" cols="35" rows="5"></textarea>
    </tr>
    </td>
    <tr>
    <td colspan="2" align="center"> <input type="submit" value="Enter"></
    td>
    </tr>
    </table>
    </form>
    </center><p>
    </body>
    </html>
    >
    Input form 2:
    <html>
    <font color="#990099" size="+1"><span
    style="font-size:18"><p>
    <TABLE cellSpacing=0 cellPadding=10 width="95%"
    align=center border=8">
    <TBODY><TR><T D vAlign=top align=left><P>< FONT
    face=arial color=bright white><b>
    <?php
    require_once('g eneric_connect. php');
    $DBName = "messages";
    $table = "messages_t bl";
    >
    $id = $_POST['id'];
    $date = $_POST['date'];
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $to = $_POST['to'];
    $text = $_POST['text'];
    >
    mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect
    to database"); // make connection to database
    mysql_select_db ($DBName) or die("Unable to select database
    $DBName"); // select database
    $sqlquery = "INSERT INTO $table VALUES('$id', '$date', '$name',
    '$subject', '$to', '$text')";
    if ($results = mysql_query($sq lquery)) {
    >
    $to = stripslashes($t o)."\r\n";
    $subject = stripslashes($s ubject);
    $text = stripslashes($t ext);
    mail($to, $subject, $text, "From: admin@work.com");
    }
    >
    mysql_close();
    print "<center><t able border=\"0\" width=\"500\">< tr><td>";
    print "<p><font face=\"verdana\ " size=\"+0\">
    <center>You Just Entered This Information into the
    Database<p><blo ckquote>";
    print "Date: $date<p>Your Name: $name<p>Message For:$to<p>Subje ct:
    $subject<p>Mess age:$text</blockquote></td></tr></table>
    </CENTER>
    </html>";
    ?>
    >
    </FONT></CENTER></b>
    </H3></TD></TR></TBODY></TABLE>
    </html><p>
    >
    portion of php.ini file that deals with mail configuration:
    >
    [mail function]
    ; For Win32 only.
    SMTP = mail.work.com
    smtp_port = 25
    >
    You mean other than this is a spammer's dream. All I have to do is post
    a form to your site with the 'to' field filled in (and others) and I
    send email anywhere I want on your nickel.

    Among other things - NEVER put the email address in you form - even as a
    hidden field.

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

    Comment

    • shimmyshack

      #3
      Re: Using SendMail in Forms w/PHP HTML

      On Apr 22, 12:23 am, j...@lycos.com wrote:
      Is there any tutorials online for sending email through forms? I can
      send an email as well as write to my MySQL database from home with the
      following code but not at work. I think there might be something I'm
      missing header-wise that keeps me from making this work on my work
      system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do
      though I'm using 5.x at home), and MySQL as the database. Thanks VERY
      much for any help or pointers to a good tutorial. I'm trying to
      provide an input form that writes to the database as well as emails
      the recipient letting them know there's been activity. Thanks, John
      >
      My form PHP code is as follows:
      >
      Input form 1:
      <html>
      <body>
      <form method="post" action="messagi ng2.php">
      <input type="hidden" name="id" value="NULL">
      <center>
      <table border="8">
      <tr>
      <td>Date:</td>
      <td align="left"><i nput type="text" name="date" size="14"
      maxlength="16" value="<? print strftime("%m/%d/%Y %H:%M"); ?>"></
      td>
      </tr>
      <tr>
      <td>Your Name:<font color=red>*</font></td><td align="left"><i nput
      type="text" name="name" size="14" maxlength="20" value=""></td>
      </tr>
      <tr>
      <td>Subject:<fo nt color=red>*</font></td><td align="left"><i nput
      type="text" name="subject" size="14" maxlength="20" value=""></td>
      </tr>
      <tr>
      <td>Message For:<font color=red>*</font></td>
      <td><select name="to" style='width: 110px;'>
      <option value = ""></option>
      <option value ="j...@lycos.co m">Joe</option>
      <option value ="r...@gmail.co m">Randy</option>
      </td>
      </tr>
      <tr>
      <td nowrap>
      Message:<font color=red>*</font></div>
      </td>
      <td>
      <textarea type="text" name="text" cols="35" rows="5"></textarea>
      </tr>
      </td>
      <tr>
      <td colspan="2" align="center"> <input type="submit" value="Enter"></
      td>
      </tr>
      </table>
      </form>
      </center><p>
      </body>
      </html>
      >
      Input form 2:
      <html>
      <font color="#990099" size="+1"><span
      style="font-size:18"><p>
      <TABLE cellSpacing=0 cellPadding=10 width="95%"
      align=center border=8">
      <TBODY><TR><T D vAlign=top align=left><P>< FONT
      face=arial color=bright white><b>
      <?php
      require_once('g eneric_connect. php');
      $DBName = "messages";
      $table = "messages_t bl";
      >
      $id = $_POST['id'];
      $date = $_POST['date'];
      $name = $_POST['name'];
      $subject = $_POST['subject'];
      $to = $_POST['to'];
      $text = $_POST['text'];
      >
      mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect
      to database"); // make connection to database
      mysql_select_db ($DBName) or die("Unable to select database
      $DBName"); // select database
      $sqlquery = "INSERT INTO $table VALUES('$id', '$date', '$name',
      '$subject', '$to', '$text')";
      if ($results = mysql_query($sq lquery)) {
      >
      $to = stripslashes($t o)."\r\n";
      $subject = stripslashes($s ubject);
      $text = stripslashes($t ext);
      mail($to, $subject, $text, "From: a...@work.com") ;
      >
      }
      >
      mysql_close();
      print "<center><t able border=\"0\" width=\"500\">< tr><td>";
      print "<p><font face=\"verdana\ " size=\"+0\">
      <center>You Just Entered This Information into the
      Database<p><blo ckquote>";
      print "Date: $date<p>Your Name: $name<p>Message For:$to<p>Subje ct:
      $subject<p>Mess age:$text</blockquote></td></tr></table>
      </CENTER>
      </html>";
      ?>
      >
      </FONT></CENTER></b>
      </H3></TD></TR></TBODY></TABLE>
      </html><p>
      >
      portion of php.ini file that deals with mail configuration:
      >
      [mail function]
      ; For Win32 only.
      SMTP = mail.work.com
      smtp_port = 25
      as you do not need to send the email addresses from the browser to the
      server in order for the server to use the value - which sent the
      emails to the browser in the first place - why not have an array in
      your logic, $arrEmailAddres ses = array( 'joe'=>'joe@ser ver.com',
      'bob'=>'bob@ser ver.com' ); and simply have values joe and bob... in
      your webpage and use the posted value - provided it exists in the
      array obtianed by array_keys($arr EmailAddresses) as the index you then
      uuse to obtain the email.

      use mysql_real_esca pe_string and if you cant - cos your it people dont
      value the aggregated learning thats gone into php5 over the attraction
      of back compatibility, then use the nearest equivalent, to stop sql
      injection, when querying your db, or else suffer the consequences.
      Dont just print back the name subject etc.. back to the webpage, first
      filter them with htmlentities or suchlike, or you have just made your
      whole website insecure, and potentially allowed users access to each
      others data in the database, even over SSL etc... etc... google for
      cross site scripting.
      dont allow email header injection, which means validate the variables
      for to subject etc... or you will still be sending email to all and
      sundry despite the steps above.

      my advice, stay away from using mail(), use an authenticated
      connection to an smtp server, using an account for the purpose of
      sending email from this form, and use a decent library like phpmailer
      to handle sending the mail, as it will be more secure.

      use a captcha or once you have been idnetified, spammers will be on
      you sending and sending. This doesnt allow mail sending unless the
      captcha is solved, its not foolproof by any means, but it makes things
      harder for the scripts out there. Big name spammers will find it easy
      to circumvent the captchas, but youve at least made the effort.

      as to why it doesnt work on your work system, -f flag is sometimes
      seen as a problem, if you authanticate to an smtp server the vaguaries
      of setups at home vs work will be moot.

      Comment

      • jcage@lycos.com

        #4
        Re: Using SendMail in Forms w/PHP HTML

        On Apr 22, 12:23 am, j...@lycos.com wrote:


        Thanks for the informative replies, gents. I forgot to mention that
        for this application that it was intended to work off a server on the
        company intranet so has some insulated security based on that (I can't
        access it from home). It began as a means to keep an electronic log
        for a 'testy' piece of equipment where messages could be passed from
        those who don't currently have access to any email. Their entries
        make it to the database log just fine where they can be queried and
        read but to ensure speedy remedies or responses to issues (by those
        who may otherwise 'forget' to check the database for any new entries),
        the ability to send an email as a teaser seemed like a good idea.
        Hence, the struggle to get some semblence of this working.

        thanks again,
        John

        Comment

        • shimmyshack

          #5
          Re: Using SendMail in Forms w/PHP HTML

          On 22 Apr, 16:05, j...@lycos.com wrote:
          On Apr 22, 12:23 am, j...@lycos.com wrote:
          >
          Thanks for the informative replies, gents. I forgot to mention that
          for this application that it was intended to work off a server on the
          company intranet so has some insulated security based on that (I can't
          access it from home). It began as a means to keep an electronic log
          for a 'testy' piece of equipment where messages could be passed from
          those who don't currently have access to any email. Their entries
          make it to the database log just fine where they can be queried and
          read but to ensure speedy remedies or responses to issues (by those
          who may otherwise 'forget' to check the database for any new entries),
          the ability to send an email as a teaser seemed like a good idea.
          Hence, the struggle to get some semblence of this working.
          >
          thanks again,
          John
          I see, although it is protected to a degree, the way the values are
          printed to the screen in fact makes it vunerable to attack from
          outside, unfortunately. It's not a massive problem, but you should use
          best practise and escape and filter wherever input is printed to
          screen or obtained from a source like a user or database and then
          used. This kind of webpage is what an external attacker is looking for
          when s/he wants to gain access to an intranet!

          Comment

          • jcage@lycos.com

            #6
            Re: Using SendMail in Forms w/PHP HTML

            I've looked at this, experimented and am confused. On form 1, the
            pull down box $to variable passes data to form 2 just fine.

            On form 1, I'm using joe & bob only and that info does come through
            fine. On form two, I tried;

            $arrEmailAddres ses = array( 'joe'=>'joe@ser ver.com',
            'bob'=>'bob@ser ver.com' ):
            array_keys($arr EmailAddresses) ;

            and leaving my TO line on the mailer portion alone:
            $mail->AddAddress($to );

            and get the following error message:
            Mailer Error: Language string failed to load: recipients_fail edjoe

            I sense that I'm missing a big part of the array keys indexing but am
            not sure. Somehow, the email address loaded into the array isn't
            getting to the mailer portion of $to



            On Apr 22, 3:49 am, shimmyshack <matt.fa...@gma il.comwrote:
            as you do not need to send the email addresses from the browser to the
            server in order for the server to use the value - which sent the
            emails to the browser in the first place - why not have an array in
            your logic, $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
            'bob'=>'...@ser ver.com' ); and simply have values joe and bob... in
            your webpage and use the posted value - provided it exists in the
            array obtianed by array_keys($arr EmailAddresses) as the index you then
            uuse to obtain the email.

            Comment

            • Timbo Twiddly

              #7
              Re: Using SendMail in Forms w/PHP HTML

              Make sure you have proper path to the language file.

              $mail->SetLanguage("e n","phpmaile r/language");

              <jcage@lycos.co mwrote in message
              news:1177864368 .543279.287540@ u30g2000hsc.goo glegroups.com.. .
              I've looked at this, experimented and am confused. On form 1, the
              pull down box $to variable passes data to form 2 just fine.
              >
              On form 1, I'm using joe & bob only and that info does come through
              fine. On form two, I tried;
              >
              $arrEmailAddres ses = array( 'joe'=>'joe@ser ver.com',
              'bob'=>'bob@ser ver.com' ):
              array_keys($arr EmailAddresses) ;
              >
              and leaving my TO line on the mailer portion alone:
              $mail->AddAddress($to );
              >
              and get the following error message:
              Mailer Error: Language string failed to load: recipients_fail edjoe
              >
              I sense that I'm missing a big part of the array keys indexing but am
              not sure. Somehow, the email address loaded into the array isn't
              getting to the mailer portion of $to
              >
              >
              >
              On Apr 22, 3:49 am, shimmyshack <matt.fa...@gma il.comwrote:
              >
              >as you do not need to send the email addresses from the browser to the
              >server in order for the server to use the value - which sent the
              >emails to the browser in the first place - why not have an array in
              >your logic, $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
              >'bob'=>'...@se rver.com' ); and simply have values joe and bob... in
              >your webpage and use the posted value - provided it exists in the
              >array obtianed by array_keys($arr EmailAddresses) as the index you then
              >uuse to obtain the email.
              >
              >

              Comment

              • Captain Paralytic

                #8
                Re: Using SendMail in Forms w/PHP HTML

                On 29 Apr, 17:32, j...@lycos.com wrote:
                I've looked at this, experimented and am confused. On form 1, the
                pull down box $to variable passes data to form 2 just fine.
                >
                On form 1, I'm using joe & bob only and that info does come through
                fine. On form two, I tried;
                >
                $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                'bob'=>'...@ser ver.com' ):
                array_keys($arr EmailAddresses) ;
                >
                and leaving my TO line on the mailer portion alone:
                $mail->AddAddress($to );
                >
                and get the following error message:
                Mailer Error: Language string failed to load: recipients_fail edjoe
                >
                I sense that I'm missing a big part of the array keys indexing but am
                not sure. Somehow, the email address loaded into the array isn't
                getting to the mailer portion of $to
                >
                On Apr 22, 3:49 am, shimmyshack <matt.fa...@gma il.comwrote:
                >
                >
                >
                as you do not need to send the email addresses from the browser to the
                server in order for the server to use the value - which sent the
                emails to the browser in the first place - why not have an array in
                your logic, $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                'bob'=>'...@ser ver.com' ); and simply have values joe and bob... in
                your webpage and use the posted value - provided it exists in the
                array obtianed by array_keys($arr EmailAddresses) as the index you then
                uuse to obtain the email.- Hide quoted text -
                >
                - Show quoted text -
                What is the line:
                array_keys($arr EmailAddresses) ;
                supposed to accomplish?

                Comment

                • Captain Paralytic

                  #9
                  Re: Using SendMail in Forms w/PHP HTML

                  On 29 Apr, 17:32, j...@lycos.com wrote:
                  I've looked at this, experimented and am confused. On form 1, the
                  pull down box $to variable passes data to form 2 just fine.
                  >
                  On form 1, I'm using joe & bob only and that info does come through
                  fine. On form two, I tried;
                  >
                  $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                  'bob'=>'...@ser ver.com' ):
                  array_keys($arr EmailAddresses) ;
                  >
                  and leaving my TO line on the mailer portion alone:
                  $mail->AddAddress($to );
                  >
                  and get the following error message:
                  Mailer Error: Language string failed to load: recipients_fail edjoe
                  >
                  I sense that I'm missing a big part of the array keys indexing but am
                  not sure. Somehow, the email address loaded into the array isn't
                  getting to the mailer portion of $to
                  >
                  On Apr 22, 3:49 am, shimmyshack <matt.fa...@gma il.comwrote:
                  >
                  >
                  >
                  as you do not need to send the email addresses from the browser to the
                  server in order for the server to use the value - which sent the
                  emails to the browser in the first place - why not have an array in
                  your logic, $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                  'bob'=>'...@ser ver.com' ); and simply have values joe and bob... in
                  your webpage and use the posted value - provided it exists in the
                  array obtianed by array_keys($arr EmailAddresses) as the index you then
                  uuse to obtain the email.- Hide quoted text -
                  >
                  - Show quoted text -
                  When I first wanted to do somethng like this I used phpformmail from

                  That shows you how to get the to: list built and looking through it
                  will give yo a lot of other hints.

                  Comment

                  • cover

                    #10
                    Re: Using SendMail in Forms w/PHP HTML

                    On 29 Apr 2007 09:32:48 -0700, jcage@lycos.com wrote:

                    So the form works fine with form 1 passing to the acknowledgement form
                    (form 2) but somehow, I need to pick from the array, the email
                    addresses associated with 'joe' and 'bob' and insert those values in
                    the mailto line of the phpmailer script that's part of form 2.

                    $arrEmailAddres ses = array( 'joe'=>'joe@ser ver.com',
                    'bob'=>'bob@ser ver.com' );

                    so the question, how can I grab only the email address from
                    $arrEmailAddres ses array above for replacement of the $to in the line
                    below?

                    $mail->AddAddress($to );

                    ie: replace as follows: "if joe, then use joe@serverlcom from array"
                    $mail->AddAddress($ar rEmailAddresses );

                    thanks,
                    John

                    Comment

                    • Captain Paralytic

                      #11
                      Re: Using SendMail in Forms w/PHP HTML

                      On 30 Apr, 14:20, cover <coverlandNOSPA M...@yahoo.comw rote:
                      On 29 Apr 2007 09:32:48 -0700, j...@lycos.com wrote:
                      >
                      So the form works fine with form 1 passing to the acknowledgement form
                      (form 2) but somehow, I need to pick from the array, the email
                      addresses associated with 'joe' and 'bob' and insert those values in
                      the mailto line of the phpmailer script that's part of form 2.
                      >
                      $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                      'bob'=>'...@ser ver.com' );
                      >
                      so the question, how can I grab only the email address from
                      $arrEmailAddres ses array above for replacement of the $to in the line
                      below?
                      >
                      $mail->AddAddress($to );
                      >
                      ie: replace as follows: "if joe, then use joe@serverlcom from array"
                      $mail->AddAddress($ar rEmailAddresses );
                      >
                      thanks,
                      John
                      As I already said, go and get phpformmail from http://www.boaddrink.com/projects/phpformmail/
                      It not only shows you how to do this but a lot more besides!

                      $mail->AddAddress($ar rEmailAddresses[$to]);

                      Comment

                      • jcage@lycos.com

                        #12
                        Re: Using SendMail in Forms w/PHP HTML

                        This is pretty weird... I have only 'joe' and 'bob' on my first form
                        pull down and they pass the name just fine through my $to variable to
                        the 2nd acknowledgment form. The array below works fine as verified
                        by using a print command on the array but for whatever reason, using
                        $mail->AddAddress($ar rEmailAddresses[$to]); as part of the form mailer
                        returns an error where if I substitute $to (with an actual address
                        from the first page, the mailer works fine and mails the message.

                        code is as follows:
                        $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                        'bob'=>'...@ser ver.com' );
                        print_r($arrEma ilAddresses[$to]);

                        the above code returns the proper email to the screen but when used
                        below, gives me back an error.

                        $mail->AddAddress($ar rEmailAddresses[$to]);

                        can someone tell me what's up with that?

                        thanks VERY much... :-)

                        Comment

                        • Captain Paralytic

                          #13
                          Re: Using SendMail in Forms w/PHP HTML

                          On 3 May, 02:36, j...@lycos.com wrote:
                          This is pretty weird... I have only 'joe' and 'bob' on my first form
                          pull down and they pass the name just fine through my $to variable to
                          the 2nd acknowledgment form. The array below works fine as verified
                          by using a print command on the array but for whatever reason, using
                          $mail->AddAddress($ar rEmailAddresses[$to]); as part of the form mailer
                          returns an error where if I substitute $to (with an actual address
                          from the first page, the mailer works fine and mails the message.
                          >
                          code is as follows:
                          $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                          'bob'=>'...@ser ver.com' );
                          print_r($arrEma ilAddresses[$to]);
                          >
                          the above code returns the proper email to the screen but when used
                          below, gives me back an error.
                          >
                          $mail->AddAddress($ar rEmailAddresses[$to]);
                          >
                          can someone tell me what's up with that?
                          >
                          thanks VERY much... :-)
                          | the above code returns the proper email to the screen but when used
                          | below, gives me back an error.
                          |
                          | $mail->AddAddress($ar rEmailAddresses[$to]);
                          |
                          | can someone tell me what's up with that?

                          Think about it! What have't you told us that you really should have?

                          Let me give you a clue: "gives me back an error."

                          WHAT ERROR?????!!!!! !

                          How are we supposed to help you when you don't tell us? We don't have
                          a crystal ball.

                          Comment

                          • jcage@lycos.com

                            #14
                            Re: Using SendMail in Forms w/PHP HTML

                            On May 3, 7:28 am, Captain Paralytic <paul_laut...@y ahoo.comwrote:
                            WHAT ERROR?????!!!!! !
                            Sorry about that.

                            "data_not_accep ted" when using: $mail-
                            >AddAddress($ar rEmailAddresses[$to]);
                            and
                            "provide_addres s" when using $mail->AddAddress =
                            ($arrEmailAddre sses[$to]);

                            with either of the above syntax, the correct address from the array IS
                            returned to the screen with the print command shown below.

                            $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                            'bob'=>'...@ser ver.com' );
                            print_r($arrEma ilAddresses[$to]);

                            i.e.
                            joe@gmail.com prints to the page just fine, just isn't working
                            properly in the "AddAddress " line.

                            Comment

                            • Captain Paralytic

                              #15
                              Re: Using SendMail in Forms w/PHP HTML

                              On 3 May, 20:36, j...@lycos.com wrote:
                              On May 3, 7:28 am, Captain Paralytic <paul_laut...@y ahoo.comwrote:
                              >
                              WHAT ERROR?????!!!!! !
                              >
                              Sorry about that.
                              >
                              "data_not_accep ted" when using: $mail->AddAddress($ar rEmailAddresses[$to]);
                              >
                              and
                              "provide_addres s" when using $mail->AddAddress =
                              ($arrEmailAddre sses[$to]);
                              >
                              with either of the above syntax, the correct address from the array IS
                              returned to the screen with the print command shown below.
                              >
                              $arrEmailAddres ses = array( 'joe'=>'...@ser ver.com',
                              'bob'=>'...@ser ver.com' );
                              print_r($arrEma ilAddresses[$to]);
                              >
                              i.e.
                              j...@gmail.com prints to the page just fine, just isn't working
                              properly in the "AddAddress " line.
                              You are trying to treat AddAddress as a method in one call and as a
                              property in another? Which is it? If it is (as I suspect) a method, I
                              would put some trace statements in it (the method) to see what is
                              giving the error. I seem to recall you saying that you managed the
                              call successfully when hard coding an address, so look at the trace in
                              both cases (hard coded/array) and you will see what the difference is.

                              Finally, once again, why not use the method that I suggested a few
                              days ago.

                              Comment

                              Working...