I have this piece of code here which sends an auto-reply to customers depending on their email request. I am trying to include a section of text which looks like this:
"This email was sent at: dd/M/yyyy - hh:ii tt"
Here is my code, located within is the parts where I want to call this date using PHP and will display once received, inside [ ].
<?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'].'
<br><br><b>Last Name: </b>'.$_POST['lastName'].'
<br><br><b>Telephone: </b>'.$_POST['phone'].'
<br><br><b>Email: </b>'.$_POST['email'].'
<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 © <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();
}
?>