【问题标题】:How to send a webpage retrieved form the database as an email to multiple emails如何将从数据库中检索到的网页作为电子邮件发送到多个电子邮件
【发布时间】:2016-09-30 07:59:16
【问题描述】:

我有一个注册页面,注册后将生成表格给申请人(包含每个申请人填写的所有表格字段),我从数据库中检索到该表格,现在我希望发送生成的表格作为多封电子邮件的邮件(由申请人在注册时提供。 这是表单检索及其响应的代码,我只想将此页面作为邮件发送到多个电子邮件,就像我上面所说的那样。 谢谢。

    <?php 
$query = "";
include("includes/connect.php");
?>
<?php
if(isset($_GET['name1'])) {
$sql = "SELECT *FROM intern_form WHERE unique_no='".$_GET['name1']."';";
$row = mysql_fetch_array(mysql_query($sql));
}
?>

<p>The Registrar,</p>
<p><?php echo $row['institution']; ?></p>
<p><?php echo $row['institution_address']; ?></p>
<p align="center"><strong>RE: APPLICATION FOR <?php echo    $row['it_duration']; ?> INDUSTRIAL TRAINING:</strong></p>

尊敬的先生/妈妈,

谨此通知您,上述学生已被接受工业实习。

我在此确认,我们将能够在我们的董事会 (ITeMS) 提供工业培训。

请在附件中找到所附的工作时间表。

谢谢。

您忠实的,

签名

【问题讨论】:

标签: php mysql sql forms email


【解决方案1】:
<?php
// send to multiple emails
$to  = 'friend1@example.com' . ', '; // first
$to .= 'friend2@example.com' . ', '; // second and other (with .=)


$subject = "Thanks for register";
$message = '
<html>
    <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Thanks for register</title>
    </head>
    <body>
        <p>Dear Sir/Ma,</p>
        <br>
        <p>This is to inform you that the above named student has been accepted for <p>industrial attachment.</p>
        <br>
        <p>I hereby comfirm that we would be in a position to offer Industrial Training in our Directorate(ITeMS).</p>
        <br>
        <p>Please find attached schedule of duty during the attachment.</p>
        <br>
        <p>Thank You.</p>
        <p>Yours faithfully,</p>
        <p>Signature</p>
    </body>
</html>';


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8 \r\n";


$headers .= "From: yournick <yournick@example.com>\r\n";
$headers .= 'Cc: secondnick@example.com' . "\r\n"; // if you want to send a copy to yourself or anybody

mail($to, $subject, $message, $headers);
?>

【讨论】:

  • 非常感谢您的回复,但是将发送到的电子邮件不是静态的,它将来自数据库并且会有所不同,来自不同的申请人,那么我如何声明变量来自数据库的电子邮件。
  • @ibrahim 告诉我你的地址是如何存储在数据库中的?
  • @ibrahim 您需要将电子邮件放入数组,然后使用类似$to = implode(', ', $emails_array);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-05
  • 1970-01-01
相关资源
最近更新 更多