Connecting Tech Pros Worldwide Forums | Help | Site Map

How to send email to multiple addresses using PHP

Newbie
 
Join Date: Dec 2006
Posts: 28
#1: Aug 28 '07
Hai frnds..
I have to send newsletters to multiple email ids which are stored in database. can i have to make a file containing all these id's from database or can i send to each of them taking from the database . please provide me a sample code...
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,439
#2: Aug 28 '07

re: How to send email to multiple addresses using PHP


Quote:

Originally Posted by syam

Hai frnds..
I have to send newsletters to multiple email ids which are stored in database. can i have to make a file containing all these id's from database or can i send to each of them taking from the database . please provide me a sample code...

How many recipients for now.?
Do you have those records already created in the database?
Newbie
 
Join Date: Dec 2006
Posts: 28
#3: Aug 28 '07

re: How to send email to multiple addresses using PHP


more than fifty recepients are there
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,439
#4: Aug 28 '07

re: How to send email to multiple addresses using PHP


Quote:

Originally Posted by syam

more than fifty recepients are there

I think you have stored them in a table, right?

you can use Php mail()
So retrieve records (email address) from table and put it to the mail function.
you do know how to use the Php with MySQL, do you?
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#5: Aug 28 '07

re: How to send email to multiple addresses using PHP


Heya, Syam.

TSDN members are expected to write their own code. We're happy to help you out if you have specific questions, but you can't realistically expect someone to do your coding for you on a free forum.
gregerly's Avatar
Expert
 
Join Date: Sep 2006
Posts: 189
#6: Aug 28 '07

re: How to send email to multiple addresses using PHP


Quote:

Originally Posted by pbmods

Heya, Syam.

TSDN members are expected to write their own code. We're happy to help you out if you have specific questions, but you can't realistically expect someone to do your coding for you on a free forum.

I'll help out with the logic to get you started:

[PHP]//select all email addresses
$sql = "SELECT emailAddress FROM emailAddress_tbl;";
$result=@mysql_query($sql);

//loop thru results and send the mail
while(list($emailAddress)=@mysql_fetch_row($result )){
//set up the mail variables
mail($emailAddress,$to,$message,$otherHeaders);
}[/PHP]

Hope that helps get you started.

Greg
Reply