0

Hello Admin and other PHP experts..!! small question, how to send email to the email IDs, that are listed in a database, i want to sent it as "noreply(at)mydomian(dot)com" and the receipents should be in BCc. And the mail i send is a HTML Advertisement of my service. help me out please... If possible, provide me the code from Line1, i.e,

<?php
$con = mysql_connect("localhost","munna","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// YOUR GIFT SCRIPT FOR ME

mysql_close($con);
?>
3
Contributors
2
Replies
7
Views
5 Years
Discussion Span
Last Post by rayidi
0

Step 1: Connecting database

`$con = mysql_connect("localhost","munna","abc123");`
// Connecting the db host.
`$db = mysql_select_db("database_name_here", $con);`
// Selecting database.

Step 2: selecting the user email addresses

    $emails = mysql_query("SELECT email FROM user");
    while($mail = mysql_fetch_array($emails)){
        $user_email = "{$mail['email']}";
        // email is the field of the email in the table user
        $admin_email = "noreply@mydomian.com";
        $subject = 'Your subject here';

        $headers = "From: No Reply <$admin_email>\r\n";
        $headers .= "Reply-To: No Reply <$admin_email>\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

        $message = "";
        // This is your greeting message

        mail($user_email, $subject, $message, $headers);
    }

Here the while loop continues untill the records finish. This will send you news letter individually. Hope this might helps you. If you have any doubts feel free to ask here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.