如何发送 PHP 包含 DATETIME 的电子邮件?

How to send PHP Email with DATETIME included?

我这里有这段代码,它根据客户的电子邮件请求向客户发送自动回复。我试图包含一段如下所示的文本:

"This email was sent at: dd/M/yyyy - hh:ii tt"

这是我的代码,位于其中的部分是我想使用 PHP 调用此日期的部分,一旦收到就会在 [ ].[= 中显示12=]

    <?php

require 'class.phpmailer.php';
require 'PHPMailerAutoload.php';

    // Set the variables from the form
    $firstName = $_POST['firstName'];
    $lastName = $_POST['lastName'];
    $telephone = $_POST['telephone'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $date = $_POST["2017"];

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                                 // Enable verbose debug output

$mail->isSMTP();                                        // Set mailer to use SMTP
$mail->Host = '***';            // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                                 // Enable SMTP authentication
$mail->Username = '***';    // SMTP username
$mail->Password = '***';                            // SMTP password
$mail->SMTPSecure = 'ssl';                              // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                      // TCP port to connect to

$mail->setFrom('***', '***');
$mail->addAddress('**');                  // Add a recipient

//$mail->addAddress('ellen@example.com');                         // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz');                   // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');              // Optional name

$mail->isHTML(true);                                                  // Set email format to HTML

$mail->Subject = '***';
$mail->Body    = $message;

$message = '<b>First Name: </b>'.$_POST['firstName'].' \r\n <br><br><b>Last Name: </b>'.$_POST['lastName'].' \r\n <br><br><b>Telephone: </b>'.$_POST['phone'].' \r\n <br><br><b>Email: </b>'.$_POST['email'].' \r\n <br><br><b>Message: </b>'.$_POST['message']; 

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been Sent';
}

if ($mail->send()){  
  $autoemail = new PHPMailer();  
  $autoemail->From = '***';  
  $autoemail->FromName = '***';  
  $autoemail->AddAddress($email); 
  $autoemail->Subject = 'Autoreply: Enquiry Submitted';  
  $autoemail->Body = '<html><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Email Confirmation</title>


<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

  </head>
  <body>
    <div class="container-full">
    <div class="row">
            <div class="col-md-12" style="padding: 30;">
                <div class="card">
                    <div class="card-img-top"><h2 align="center">Your Latest Enquiry</h2>
                    <div class="card-block">
                        <h4 class="card-title mt-3" align="center">Hi '.$_POST["firstName"].',</h4>
                        <div class="card-text">
                            <p align="center">Thank you for your Enquiry, we aim to give a response as quick as possible.<br/>On the term that we have forgotten to contact you within 48hrs, please give us a <b><u><a href="http://www.allensautocleanse.co.uk/contact">call</a></u></b>.</p>
                        </div>
                    </div>
                    <div class="card-footer" align="center">
                        <small>This email was sent at: **[CURRENT DATETIME INSERTED HERE!]**</small> 
                    </div>
                </div>
            </div>
        </div> 
    </div>
    <footer>
    <div class="col-md-6">
    <p>Copyright &copy; <b>**** - **[CURRENT YEAR INSERTED HERE!]**</p> 
    </b>
    </div>
    </footer>
</div>
</body>
  </html>';
  $autoemail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 

    //Call the auto send method 
   $autoemail->Send();  
}  

?>

试试日期函数

<small>This email was sent at: **[<?php echo date("dd/M/YY HH:i:s");]**</small> 

您可以在

查找不同的格式

https://www.w3schools.com/php/func_date_date.asp