how to sent mail to more that 1 email at the same time

Discussion in 'PHP' started by adsegzy, Jul 14, 2010.

  1. #1
    Hello friends,

    I know hot to code my form to send mail to the only one enter email, but when i try to enter more thatn one email and seperate them with comma(,) the mail did not go, how can i do it.

    regards
     
    adsegzy, Jul 14, 2010 IP
  2. uzairjawed

    uzairjawed Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    loop over the mail function dude.
     
    uzairjawed, Jul 14, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Loop through, heres a basic example...

    <?php
    //comma seperated list...
    $emails = "hey@danx10.com,admin@digitalpoint.com";
    
    $emails_array = explode(",", $emails);
    
    foreach($emails_array as $email) {
    //place mail() or whatever here... and use $email as the recipient?
    }
    ?>
    PHP:
     
    danx10, Jul 14, 2010 IP
  4. dbsuk

    dbsuk Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The following works on my test server, both emails are sent.

    
    mail("firstemail@test.com, secondemail@test.com", "Two mails at once", "This is a test");
    
    PHP:
     
    dbsuk, Jul 15, 2010 IP