Birden reseptör php e-posta göndermek - mysqli

0 Cevap php

Ben bu yüzden benim veritabanı tablosundan tüm seçin ve onlara bir mail göndermek istiyorum ve de ben bu olabilir ancak nasıl seçilen e-postalar göndermek istiyorsun zaten benim veritabanında saklanır kullanıcılara postalar göndermek için bilmek istiyorum tamam

Bu yönetici arayüzü ilgili kodu:

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

Ben bu konuda yardıma ihtiyacım var lütfen

Bu benim yeni kodu

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

0 Cevap