Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // session_start();
- //****CONFIG****//
- //message to be displayed to the user
- //Date and time stamp to create reference number:
- date_default_timezone_set('Europe/London');
- $date = new DateTime();
- $referenceNo = $date->format('si / hd - my');
- //ATTACHMENTS
- //set max size
- $maxsize = 2 * 1024 * 1024; // 2 MB
- //set allowed file types
- $types = array(
- 'image/png',
- 'image/jpeg',
- 'image/gif',
- 'application/msword',
- 'application/pdf'
- );
- if($_POST) {
- $formName = "Quick Quote";
- $emailSubject = ucwords("Adtrak Website - $formName Enquiry");
- //require the mailer
- require_once("assets/class.phpmailer.php");
- require_once("assets/class.smtp.php");
- //initialise a mail() instance
- $emailFrom = $_POST['Email'];
- $replyTo = $_POST['Email'];
- //Clockwork SMTP Settings
- $mail=new PHPMailer();
- $mail->IsSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
- $mail->Port = 465; // Set the SMTP port
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'info.website@clockworkremovals.co.uk'; // SMTP username
- $mail->Password = 'sdTWw2wFaWUv'; // LIVE API KEY
- $mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted]
- $mailCustomer =new PHPMailer();
- $mailCustomer->IsSMTP(); // Set mailer to use SMTP
- $mailCustomer->Host = 'smtp.gmail.com'; // Specify main and backup server
- $mailCustomer->Port = 465; // Set the SMTP port
- $mailCustomer->SMTPAuth = true; // Enable SMTP authentication
- $mailCustomer->Username = 'info.website@clockworkremovals.co.uk'; // SMTP username
- $mailCustomer->Password = 'sdTWw2wFaWUv'; // LIVE API KEY
- $mailCustomer->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
- //set variables
- //subject
- $mail->Subject = $emailSubject;
- $mailCustomer->Subject = "$companyName | Thanks for getting in touch!";
- //destination email address
- // $mail->AddAddress($emailTo, $emailTo);
- foreach($emailToArray as $emailTo) {
- $mail->AddAddress($emailTo, $emailTo);
- }
- $mailCustomer->AddAddress($emailFrom, $emailFrom);
- //sender Name
- $mail->FromName = $companyName;
- $mailCustomer->FromName = $companyName;
- //reply to Email address
- $mail->AddReplyTo($replyTo, $replyTo);
- $mailCustomer->AddReplyTo($emailTo, $emailTo);
- //create the mail message to go to the client
- $msg = "<html><body style=\"font-family:Arial, sans-serif; font-size:12px; padding: 0; margin: 0px; color:#555;\"><div style=\"padding: 20px\">";
- $msg .= "<h1 style=\"font-family:Arial, sans-serif; font-size: 16px;\">$companyName | $emailSubject</h1>";
- $msg .= "<h2 style=\"font-family:Arial, sans-serif; font-size: 14px;\">from $emailFrom | Reference Number: $referenceNo</h2>";
- $msg .= "<table style=\"padding:2%; margin:0; width: 96%; background-color: #fafafa;\" >";
- //customer copy
- $msgCustomer = "<html><body style=\"font-family:Arial, sans-serif; font-size:12px; padding: 0; margin: 0px; color:#555;\">";
- $msgCustomer .= "<h1 style=\"font-family:Arial, sans-serif; font-size: 16px;\">$companyName | $formName</h1>";
- $msgCustomer .= "<h2 style=\"font-family:Arial, sans-serif; font-size: 14px;\">from $emailTo | Reference Number: $referenceNo</h2>";
- $msgCustomer .= "<p style=\"font-family:Arial, sans-serif; font-size: 12px;\">Thanks for getting in touch. We have received your message and we'll get back to you as soon as possible. </p>";
- $msgCustomer .= "<p style=\"font-family:Arial, sans-serif; font-size: 12px;\">A copy of your message is included below.</p>";
- $msgCustomer .= "<table style=\"padding:2%; margin:0; width: 96%; background-color: #fafafa;\" >";
- //loop through posted data
- foreach($_POST as $data => $value) {
- //debugging
- if($data !== "form_name" && $data != "upload" && $data != "botBuster" && $data !="submit_contact_form") {
- $i = str_replace("_"," ",ucfirst($data));
- $msg .= "<tr style=\"border-bottom: 1px solid #ccc;\">";
- $msg .= "<td valign=\"center\" style=\"width: 20%; background-color: #fff; font-family:Arial, sans-serif; padding:8px 10px; margin:0; font-size:12px; font-weight: bold;\">". str_replace(" $value"," ",$i) ."</td>\n";
- $msg .= "<td valign=\"center\" style=\"width: 65%; background-color: #fff; font-family:Arial, sans-serif; font-size: 12px; padding:8px 10px;margin:0;\">".$value."</td>\n";
- $msg .= "</tr>";
- //customer copy
- $msgCustomer .= "<tr style=\"border-bottom: 1px solid #ccc;\">";
- $msgCustomer .= "<td valign=\"center\" style=\"width: 20%; background-color: #fff; font-family:Arial, sans-serif; padding:8px 10px; margin:0; font-size:12px; font-weight: bold;\">". str_replace(" $value"," ",$i) ."</td>\n";
- $msgCustomer .= "<td valign=\"center\" style=\"width: 65%; background-color: #fff; font-family:Arial, sans-serif; font-size: 12px; padding:8px 10px;margin:0;\">".$value."</td>\n";
- $msgCustomer .= "</tr>";
- }
- }//endforeach
- $msg .= "</table>
- <p style=\"display: block; font-family: Arial; font-size: 12px;\">This email has come from your <a href=\"http://www.adtrak.co.uk\">Adtrak</a> Website</p></body></html>";
- //customer copy
- $msgCustomer .= "</table>
- <p style=\"display: block; font-family: Arial; font-size: 12px;\">You have received this Email because you completed a form on our website.</p></div></body></html>";
- //set the email message to $msg
- $mail->MsgHTML($msg);
- //customer copy
- $mailCustomer->MsgHTML($msgCustomer);
- if(!$mail->Send()) {
- //If mail couldn't be sent output error.
- echo '<div id="results"><ul><li>We are very sorry, but there was an error sending your enquiry. Please contact us by telephone.</li></ul></div>';
- // die($output);
- }
- elseif (!empty($_POST['botBuster'])) {
- //If mail couldn't be sent output error.
- echo '<div id="results"><ul><li>We are very sorry, but there was an error sending your enquiry. Please contact us by telephone.</li></ul></div>';
- // die($output);
- }
- else {
- if($emailTo !== $emailFrom) {
- $mailCustomer->Send();
- }
- header('Location: '. $destination);
- // die($output);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement