Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1111951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:37:51+00:00 2026-05-17T02:37:51+00:00

I’d like to know how to send mails to users who is already stored

  • 0

I’d like to know how to send mails to users who is already stored in my database so I want to select all from my database table and send them a mail and also is I want to send to the selected emails only how that can be done

This is the relevant code of the admin interface:

<?php 

        $get_U_data = " select * from maling_list ";
        $result = $db -> query ($get_U_data) or die ($db->error);
        if ($result) {
?>
<h2>Send your newsletter</h2>

<form action="mailit.php" method="post" >
Category:
<select name="category">
        <option value="1">option1</option>
        <option value="2">option2</option>
        <option value="3">option3</option>
        <option value="4">option4</option>
</select>
<select name="select" size="15" multiple="multiple" id="select">
      <option>--------------</option>
      <?php 
      while ($row = $result -> fetch_object()) {
      ?>
      <option><?php echo $row->company ?><br /></option>
<?php
      }
}
?>
      <option>--------------</option>
</select><br />
Subject: <input type="text" name="subject" /><br />
Message<: <textarea name="body" cols="60" rows="15"></textarea><br>
<input type="submit" name="submit" value="Send" />
</form>

please I need help on this

this is my new code

<?php
  include_once("../admin_config/config.php");
  $getMails = " select * from maling_list where received = 0 limit 20 ";
  $result = $db->query($getMails) or die($db->error);
  $dbfailures = array();
  $failures = array();
  $success = array();
  while ($row = $result->fetch_array()) {
      $email = $row['email'];
      $name = $row['company'];
      $subject = $_POST['subject'];
      $cat = $_POST['category'];
      $mailbody = $_POST['body'];
      $headers = "From : add@egindex.com\r\n";
      $to = "$email";
      $mailResult = mail($to, $subject, $mailbody, $cat, $headers);
      if ($mailResult) {
          $updataData = " UPDATE mailing_list SET received = '1' where email = '" . $db->real_escape_string($email) . "' LIMIT 1";
          $resultUpdate = $db->query($updataData) or die($db->error);
          if ($resultUpdate) {
              $success[] = $email;
          } else {
              $dbfailures[] = $email;
          }
      } else {
          $failures[] = $email;
      }
  }
  echo "These mails didn't get sent: " . htmlentities(implode(', ', $failures)) . "<br />" . "These mails didn't get updated in db: " . htmlentities(implode(', ', $dbfailures)) . "<br />" . "These mails were successfully sent: " . htmlentities(implode(', ', $success));
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:37:51+00:00Added an answer on May 17, 2026 at 2:37 am

    you may want to have a look at this – http://www.php.net/manual/en/function.mail.php#85476

    <?php
    
    $mailbody = "";
    $subject = "Egindex newsletter";
    $headers.= "From : Newsletter@egindex.com\r\n";
    $headers.= "Content-type: text/html\r\n";
    $to = '';
    
    $headers.="Bcc: ";
    while ($row = $result->fetch_array()) {
        $headers.=$row['email'].", ";
    }
    $headers.="admin@mailinglist.com\r\n";
    
    $mailResult = mail($to, $subject, $mailbody, $headers);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have two tables with like below codes: Table: Accounts id | username |
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I would like to count the length of a string with PHP. The string
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.