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);
?>

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.