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

Code:

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

I want to send email with attached pdf files to the email users listed in the table. I have a generated pdf files in a folder called "slips" which has the emails as the filename for example every filename bears the name of the emails in the database eg. smith@test.com in the email column and a pdf file named smith@test.com.pdf

What is the best php code to use for such problem.

Try this to send a PDF attachment in your email,

http://swiftmailer.org/docs/messages.html