Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Send emails to all member in database table

the mail() function

Moderators: macek, egami, gesf

Send emails to all member in database table

Postby manish009 » Fri Apr 29, 2011 9:00 pm

I have made a database using phprunner. All things have done but i am unable to put emails option to my database.
I want to send emails to all who are listed in one column of database.
I dont have any knowledge of php and html can you help in details. its too urgent.

Thank you
Manish Kumar
.
manish009
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Apr 29, 2011 8:58 pm

Re: Send emails to all member in database table

Postby ZetaPrints » Mon May 02, 2011 9:23 am

You can make use of PHP's mail() function to send an email for every data fetched by your query. Your code might look something like this:

Code: Select all
$query  = "SELECT email FROM contacts";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
   $to = $row['email'];  // from your database
    $subject = "Hello";
    $content = "Content of Email";
 
   if (mail($to, $subject, $body)) {
         echo("<p>Message successfully sent!</p>");
     } else {
         echo("<p>Message delivery failed...</p>");
     }
}
ZetaPrints
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Feb 01, 2011 11:56 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron