【问题标题】:Send pdf attachment to emails in mysql database using php使用php将pdf附件发送到mysql数据库中的电子邮件
【发布时间】:2015-07-08 12:48:40
【问题描述】:

代码:

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

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

解决此类问题的最佳 php 代码是什么。

【问题讨论】:

    标签: php mysql pdf-generation email-attachments


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-20
      • 2014-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-07
      • 2014-05-29
      相关资源
      最近更新 更多