Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5

Thread: Parsing script

  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    In php parsing script, how could I alter these lines (marked on red) to get the results from the questionnaire to 3 different email addresses (instead of one, as it is now).

    Thank you very much

    <?
    @import_request_variables("gpc");
    $youremail = "pierrot@yahoo.com";
    $subject = "questionaire";
    ?>

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    You have 2 ways really.

    You can either list the e-mail addresses in the same variable and pass that to the mail function. You have to separate each e-mail address with a comma. See the below example

    PHP Code:
    <?php

    $to 
    "address@domain.com, address@anotherdomain.com";
    $subject "New e-mail";
    $message "Hello";
    $from "youraddress@domain.com";
    $headers "From: $from\r\n";

        if(
    mail($to$subject$message$headers))
        {
            echo 
    "<p>E-mail to $to sent.</p>";
        }
    ?>
    One concern (of mine) would be that if one address was not working then the mail function call will fail.

    So, another way will be to create an arry of the e-mail addresses you want and call the mail function n times (where n is the number of addresses to e-mail). See example below

    PHP Code:
    <?php

    $to 
    "address@domain.com, address@anotherdomain.com";
    $subject "New e-mail";
    $message "Hello.";
    $from "youraddress_domain.com";
    $headers "From: $from\r\n";

    $arrayAddresses explode(" "$addresses);

    foreach(
    $arrayAddresses as $key => $to)
    {
        if(
    mail($to$subject$message$headers))
        {
            echo 
    "<p>E-mail to $to sent.</p>";
        }
    }
    ?>
    The explode line just creates an array, if you want a further explanation visit http://uk2.php.net/manual/en/function.explode.php

  4. #3
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    Shouldn't that be

    Code:
    $arrayAddresses = explode(",", $addresses);   // ie. comma
    ?

    Sean

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Yeah, I had the e-mail addresses split by a space " " but then changed it to a comma so that the variable could be given to mail() instead of looping through.

    So either/or really.

  6. #5
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Thank you very much for helping me.
    The first example is working perfectly well !!!

    :-)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:14 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com