Advanced Search

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: PHP Only Sending To One Email

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Only Sending To One Email

    Hi all... I have the following

    PHP Code:
    mail($to"Membership Status"$msg'From: '.$from); 
    And then have this in the $to

    PHP Code:
    $to "domain1@email.com, domain2@email.com, domain3@email.com, domain4@email.com, domain5@email.com"
    It's only sending to the first email... But in the email that get's sent to the first email address I can see all those email addresses in the to field... Any ideas?

  2. #2
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'd rather suspect your mail transport rather than PHP. What system are you on , what are your SMTP settings (and what software have you been using to send mail)?

  3. #3
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm sending it through the server, it's a PHP page... Are you asking what software the server is running? It's a Windows IIS server...

  4. #4
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by tomyknoker View Post
    I'm sending it through the server[...]It's a Windows IIS server...
    And that can be the problem:
    from PHP manual:
    The Windows implementation of mail() differs in many ways from the Unix implementation.[...] a MTA is needed listening on a network socket.[...] to parameter should not be an address in the form of "Something <someone@example.com>". The mail command may not parse this properly while talking with the MTA.
    Therefore you need to check if your MTA, that receives the mail doesn't actually bounce it in the first place.

  5. #5
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    PHP Code:
    while ($to "domain1@email.com, domain2@email.com, domain3@email.com, domain4@email.com, domain5@email.com";)
     {
     
    mail($to"Membership Status"$msg'From: '.$from); 


  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,830
    Thanks
    231
    Thanked 659 Times in 647 Posts

    Default

    Hmm... I don't think that would do it.

    Using a while and running through each, splitting at a comma might.

    But that will run infinitely, since $to will continuously assume the value of the string, without any factors changing.
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,797
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try this:

    Code:
    <?php
    
    // All of the email addresses the message needs to be sent to
    $addresses = Array('me@domain.com','you@domain.com','test@example.com','email@website.com');
    
    //the subject of the message
    $subject = 'Test Email';
    
    //The body of the message
    $msg = <<<HERE
    This is the test email message. Change me to what you want the email to say
    HERE;
    
    foreach ($addresses as $to) {
     mail($to, $subject, $msg, 'From: PHP Script <noreply@domain.com>');
    }
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,830
    Thanks
    231
    Thanked 659 Times in 647 Posts

    Default

    You could replace the first thing with this and make it easier to write:
    PHP Code:
    $addresses explode(', ''me@domain.com, you@domain.com, test@example.com, email@web.com'); 
    Last edited by djr33; 05-04-2007 at 06:49 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

  9. #9
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Guys thanks for the help... I'll give it a goadn keep you posted...

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,830
    Thanks
    231
    Thanked 659 Times in 647 Posts

    Default

    Oh, oops. It should be ', ' not just ','
    //Edited above
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

Bookmarks

Posting Permissions

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