I think this is what you want to do:

<?
$sms_list = "test_number"; // This is the file with one e-mail address
per line?
$emails = file($sms_list);

foreach($emails as $this_is_one_address) {
        // Do what ever you want to.
        // $this_is_one_address contains one element from $emails
};


Niklas



-----Original Message-----
From: Chris Grigor [mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 8:59
To: 'Php-General-List (E-mail)'
Subject: [PHP] foreach statement 


Okay lets see who has there thinking caps on today (cos I really dont)

I have a list of email addresses stored in a text file.

I am able to run the script and get all the mail addresses in the list
mailed but 
thats all in one mail. I want to be able to open the file, chop each
line and send 
individual messages to each address.. okay who is confused as Im not
giving you much 
description here, well okay heres what the script looks like....

#!/usr/bin/php -q

<?


        $sms_list = "test_number";
        $emails = file($sms_list);

        for ($i=0; $i < count($emails); $i++) $emails[$i] =
trim($emails[$i]);
                $recipient = implode(",", $emails);

print "$recipient";


{

        $mail_subject="test this";
        $mail_body="testing";
        mail($recipient, $mail_subject, $mail_body);
        print "mail sent\n";

        }


?>


Im just thinking(trying to at least) I need some sort of foreach
statement like in perl, right? 
so that it would say 

foreach($recipient)
        { 
send mail 
}


anyone that could maybe guide me? 

Thanks in advance

C-Ya

Chris Grigor
------------------------------------------------------------------------
----
--------------
Client Services
Call Center: 0860 100 154
Fax: +27 11 340 7345
E-Mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
----
--------------
M-WEB Business Solutions
Making it happen.

Go shopping @ http://shopping.mweb.co.za 
Get your business online @ http://business.mweb.com 

"We all know Linux is great...it does infinite loops in 5 seconds."
- Linus Torvalds

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to