如何将从数据库中检索到的网页作为电子邮件发送到多个电子邮件

时间:2016-06-01 05:48:10

标签: php mysql sql forms email

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

    <?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)提供工业培训。

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

谢谢。

忠实地,你

签名

1 个答案:

答案 0 :(得分:0)

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