User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,437 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,642 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 457 | Replies: 5
Reply
Join Date: Nov 2006
Posts: 37
Reputation: Firestone is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Firestone Firestone is offline Offline
Light Poster

Mailing to an array

  #1  
Aug 5th, 2007
I'm trying to email to an array of subscribers to a weekly newsletter. Whenever I try though, I get an error "Bad parameters to function mail()". Heres the loop I'm using to mail:

  1. $x = 0;
  2. $y = 1;
  3. while ($x <= $y)
  4. {
  5. mail($names[$x], "Hey", "Whats up?");
  6. $x++;
  7. }

Any help would be appreciated, thanks.
Last edited by Firestone : Aug 5th, 2007 at 5:47 pm.
=================================
There are 10 types of people in the world,
Those who understand binary, and those who don't
=================================
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Italy
Posts: 42
Reputation: cereal is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
cereal cereal is offline Offline
Light Poster

Re: Mailing to an array

  #2  
Aug 5th, 2007
Check the array. While function works fine to me. I have done it like this:

  1. $names[] = 'name1@host.tld';
  2. $names[] = 'name2@host.tld';
  3. $names[] = 'name3@host.tld';
  4.  
  5. $x = 0;
  6. $y = 2;
  7. while ($x <= $y)
  8. {
  9. mail($names[$x], "hey", "whats up?");
  10. $x++;
  11. }

Bye.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 3,090
Reputation: Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold 
Rep Power: 15
Solved Threads: 307
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Sensei

Re: Mailing to an array

  #3  
Aug 6th, 2007
If you use foreach() you won't even need to bother with the indexing.
  1. <?php
  2. $list[] = "first";
  3. $list[] = "second";
  4. $list[] = "third";
  5.  
  6. foreach ($list as $entry){
  7. mail($entry, "Hey", "Whats up?");
  8. }
  9. ?>
Reply With Quote  
Join Date: Nov 2006
Posts: 37
Reputation: Firestone is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Firestone Firestone is offline Offline
Light Poster

Re: Mailing to an array

  #4  
Aug 6th, 2007
I populated the array with a loop, that read the names from a text file. I tried doing it manually, and it worked, but I cant do it that way for what I'm doing. @Ezzaral: What is foreach()? Would that help?
=================================
There are 10 types of people in the world,
Those who understand binary, and those who don't
=================================
Reply With Quote  
Join Date: Jul 2007
Location: Sofia, Bulgaria
Posts: 138
Reputation: MitkOK is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
MitkOK's Avatar
MitkOK MitkOK is offline Offline
Junior Poster

Re: Mailing to an array

  #5  
Aug 6th, 2007
foreach()

- Mitko Kostov
Reply With Quote  
Join Date: Jan 2006
Location: Balkh
Posts: 67
Reputation: jamshid is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jamshid's Avatar
jamshid jamshid is offline Offline
Junior Poster in Training

Re: Mailing to an array

  #6  
Aug 8th, 2007
Also this More Simple.
Impossible is Nothing
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC