Advertisement
Guest User

Untitled

a guest
Jul 12th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. <?php
  2. // session_start();
  3. //****CONFIG****//
  4.  
  5. //message to be displayed to the user
  6.  
  7. //Date and time stamp to create reference number:
  8. date_default_timezone_set('Europe/London');
  9. $date = new DateTime();
  10. $referenceNo = $date->format('si / hd - my');
  11.  
  12. //ATTACHMENTS
  13. //set max size
  14. $maxsize = 2 * 1024 * 1024; // 2 MB
  15.  
  16. //set allowed file types
  17. $types = array(
  18. 'image/png',
  19. 'image/jpeg',
  20. 'image/gif',
  21. 'application/msword',
  22. 'application/pdf'
  23. );
  24.  
  25. if($_POST) {
  26.  
  27. $formName = "Quick Quote";
  28. $emailSubject = ucwords("Adtrak Website - $formName Enquiry");
  29.  
  30. //require the mailer
  31. require_once("assets/class.phpmailer.php");
  32. require_once("assets/class.smtp.php");
  33.  
  34. //initialise a mail() instance
  35.  
  36. $emailFrom = $_POST['Email'];
  37. $replyTo = $_POST['Email'];
  38.  
  39. //Clockwork SMTP Settings
  40. $mail=new PHPMailer();
  41. $mail->IsSMTP(); // Set mailer to use SMTP
  42. $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
  43. $mail->Port = 465; // Set the SMTP port
  44. $mail->SMTPAuth = true; // Enable SMTP authentication
  45. $mail->Username = 'info.website@clockworkremovals.co.uk'; // SMTP username
  46. $mail->Password = 'sdTWw2wFaWUv'; // LIVE API KEY
  47. $mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted]
  48.  
  49. $mailCustomer =new PHPMailer();
  50. $mailCustomer->IsSMTP(); // Set mailer to use SMTP
  51. $mailCustomer->Host = 'smtp.gmail.com'; // Specify main and backup server
  52. $mailCustomer->Port = 465; // Set the SMTP port
  53. $mailCustomer->SMTPAuth = true; // Enable SMTP authentication
  54. $mailCustomer->Username = 'info.website@clockworkremovals.co.uk'; // SMTP username
  55. $mailCustomer->Password = 'sdTWw2wFaWUv'; // LIVE API KEY
  56. $mailCustomer->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
  57.  
  58. //set variables
  59. //subject
  60. $mail->Subject = $emailSubject;
  61. $mailCustomer->Subject = "$companyName | Thanks for getting in touch!";
  62. //destination email address
  63. // $mail->AddAddress($emailTo, $emailTo);
  64. foreach($emailToArray as $emailTo) {
  65. $mail->AddAddress($emailTo, $emailTo);
  66. }
  67. $mailCustomer->AddAddress($emailFrom, $emailFrom);
  68. //sender Name
  69. $mail->FromName = $companyName;
  70. $mailCustomer->FromName = $companyName;
  71. //reply to Email address
  72. $mail->AddReplyTo($replyTo, $replyTo);
  73. $mailCustomer->AddReplyTo($emailTo, $emailTo);
  74.  
  75. //create the mail message to go to the client
  76. $msg = "<html><body style=\"font-family:Arial, sans-serif; font-size:12px; padding: 0; margin: 0px; color:#555;\"><div style=\"padding: 20px\">";
  77. $msg .= "<h1 style=\"font-family:Arial, sans-serif; font-size: 16px;\">$companyName | $emailSubject</h1>";
  78. $msg .= "<h2 style=\"font-family:Arial, sans-serif; font-size: 14px;\">from $emailFrom | Reference Number: $referenceNo</h2>";
  79.  
  80. $msg .= "<table style=\"padding:2%; margin:0; width: 96%; background-color: #fafafa;\" >";
  81.  
  82. //customer copy
  83. $msgCustomer = "<html><body style=\"font-family:Arial, sans-serif; font-size:12px; padding: 0; margin: 0px; color:#555;\">";
  84. $msgCustomer .= "<h1 style=\"font-family:Arial, sans-serif; font-size: 16px;\">$companyName | $formName</h1>";
  85. $msgCustomer .= "<h2 style=\"font-family:Arial, sans-serif; font-size: 14px;\">from $emailTo | Reference Number: $referenceNo</h2>";
  86. $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>";
  87. $msgCustomer .= "<p style=\"font-family:Arial, sans-serif; font-size: 12px;\">A copy of your message is included below.</p>";
  88. $msgCustomer .= "<table style=\"padding:2%; margin:0; width: 96%; background-color: #fafafa;\" >";
  89.  
  90. //loop through posted data
  91. foreach($_POST as $data => $value) {
  92. //debugging
  93.  
  94. if($data !== "form_name" && $data != "upload" && $data != "botBuster" && $data !="submit_contact_form") {
  95. $i = str_replace("_"," ",ucfirst($data));
  96. $msg .= "<tr style=\"border-bottom: 1px solid #ccc;\">";
  97. $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";
  98.  
  99. $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";
  100. $msg .= "</tr>";
  101.  
  102. //customer copy
  103. $msgCustomer .= "<tr style=\"border-bottom: 1px solid #ccc;\">";
  104. $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";
  105. $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";
  106. $msgCustomer .= "</tr>";
  107.  
  108. }
  109.  
  110.  
  111. }//endforeach
  112.  
  113. $msg .= "</table>
  114. <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>";
  115. //customer copy
  116. $msgCustomer .= "</table>
  117. <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>";
  118.  
  119. //set the email message to $msg
  120. $mail->MsgHTML($msg);
  121. //customer copy
  122. $mailCustomer->MsgHTML($msgCustomer);
  123.  
  124. if(!$mail->Send()) {
  125. //If mail couldn't be sent output error.
  126. 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>';
  127. // die($output);
  128. }
  129. elseif (!empty($_POST['botBuster'])) {
  130. //If mail couldn't be sent output error.
  131. 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>';
  132. // die($output);
  133. }
  134. else {
  135. if($emailTo !== $emailFrom) {
  136. $mailCustomer->Send();
  137. }
  138. header('Location: '. $destination);
  139. // die($output);
  140. }
  141.  
  142.  
  143.  
  144. }
  145.  
  146. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement