使用php向mysql数据库中的电子邮件发送pdf附件

使用php向mysql数据库中的电子邮件发送pdf附件,php,mysql,pdf-generation,email-attachments,Php,Mysql,Pdf Generation,Email Attachments,代码: 名称 电子邮件 全选 } 我想向表中列出的电子邮件用户发送附有pdf文件的电子邮件。我在一个名为“slips”的文件夹中生成了一个pdf文件,该文件夹将电子邮件作为文件名,例如,每个文件名都带有数据库中电子邮件的名称,例如。smith@test.com在电子邮件列和名为smith@test.com.pdf 对于这样的问题,最好的php代码是什么 尝试在电子邮件中发送PDF附件 <?php $servername = "localhost"; $usernam

代码:


名称
电子邮件
全选
}
我想向表中列出的电子邮件用户发送附有pdf文件的电子邮件。我在一个名为“slips”的文件夹中生成了一个pdf文件,该文件夹将电子邮件作为文件名,例如,每个文件名都带有数据库中电子邮件的名称,例如。smith@test.com在电子邮件列和名为smith@test.com.pdf


对于这样的问题,最好的php代码是什么

尝试在电子邮件中发送PDF附件

   <?php
   $servername = "localhost";
    $username = "username";
   $password = "****";
   // Create connection
   $conn = new mysqli($servername, $username, $password);
   // Check connection
     if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }
$sql = "SELECT email, name FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

$conn->close();

    ?>


<table width="348" border="0">
 <tr>
   <td width="88">Name</td>
<td width="98">Email</td>
<td width="148">Select All

    <label>
      <input type="checkbox" name="checkbox" id="checkbox">
    </label>    </td>
 </tr>
 <tr>
<?php {?><td><?php echo $row["name"];?>
    }
</td>
<td><?php echo $row["email"];?></td>
<td><label>
  <input type="checkbox" name="checkbox" id="checkbox">
</label></td><?php } else {
echo "0 results";
}?>
  </tr>
  <tr>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td><label>
  <input type="submit" name="button" id="button" value="Send">
 </label></td>
    </tr>
 </table>
http://swiftmailer.org/docs/messages.html