Advertisement
tjromano

phpmailer auto

May 11th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.80 KB | None | 0 0
  1. <?php session_start();
  2. //ini_set('display_errors', 'On');
  3. //error_reporting(E_ALL);
  4.  
  5.  
  6. /* *********** FUNCTIONS ****************** */
  7.  
  8. function checkit($insuredName) {
  9. return(str_replace(array("\r", "\n", "%OA", "%oa", "%OD", "%od", "Content-Type:","BCC:","bcc:"), "", $insuredName));
  10. }
  11.  
  12. function cleanUp($data) {
  13. $data = trim(strip_tags(htmlspecialchars($data)));
  14. return $data;
  15. }
  16.  
  17. $referer=$_SERVER['HTTP_REFERER'];
  18. #print($referer);
  19. $refsplit=explode("?",$referer);
  20. #if($refsplit[0]=='http://www.tracy-driscoll.com/landingpages/auto/quote2.html'){
  21.  
  22. $errorFields = array();
  23.  
  24. if (isset($_POST['submit'])) {
  25. echo "got to this stage<br />";
  26. $insuredName =cleanUp($_POST['insuredName']);
  27. $address=cleanUp($_POST['address']);
  28. $city=cleanUp($_POST['city']);
  29. $state=cleanUp($_POST['state']);
  30. $zip=cleanUp($_POST['zip']);
  31. $phone=cleanUp($_POST['phone']);
  32. $email=cleanUp($_POST['email']);
  33. $dobMonth=cleanUp($_POST['dobMonth']);
  34. $dobDay=cleanUp($_POST['dobDay']);
  35. $dobYear=cleanUp($_POST['dobYear']);
  36. $driversLicense=cleanUp($_POST['driversLicense']);
  37. $doYou=cleanUp($_POST['doYou']);
  38. $bodilyInjury=cleanUp($_POST['bodilyInjury']);
  39. $propertyDamage=cleanUp($_POST['propertyDamage']);
  40. $medicalPayments=cleanUp($_POST['medicalPayments']);
  41. $comprehensiveDeductible=cleanUp($_POST['comprehensiveDeductible']);
  42. $collisionDeductible=cleanUp($_POST['collisionDeductible']);
  43. $rentalReimbursement=cleanUp($_POST['rentalReimbursement']);
  44. $towing=cleanUp($_POST['towing']);
  45. $v1year=cleanUp($_POST['v1year']);
  46. $v1make=cleanUp($_POST['v1make']);
  47. $v1vin=cleanUp($_POST['v1vin']);
  48. $v2year=cleanUp($_POST['v2year']);
  49. $v2make=cleanUp($_POST['v2make']);
  50. $v2vin=cleanUp($_POST['v2vin']);
  51. $otherDrivers=cleanUp($_POST['otherDrivers']);
  52. $howMany=cleanUp($_POST['howMany']);
  53. $permission=cleanUp($_POST['permission']);
  54. $ssn=cleanUp($_POST['ssn']);
  55.  
  56. if (!strlen($insuredName)) array_push($errorFields, 'insuredName');
  57. if (!strlen($email)) array_push($errorFields, 'email');
  58. if (!strlen($phone)) array_push($errorFields, 'phone');
  59. echo "got here step 2";
  60.  
  61. #check for valid e-mail address
  62. if (!preg_match("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$^",$email)) {
  63. array_push($errorFields, 'email');
  64. die("Invalid Email Address. Email will not be sent");
  65. }
  66.  
  67. #die if there are line returns in the name or e-mail field
  68. //if (!preg_match("\r",$insuredName) || !preg_match("\n",$insuredName) || !preg_match("\r",$email) || !preg_match("\n",$email)){
  69. //die("Why ?? :(");
  70. //}
  71.  
  72. if (!count($errorFields)) {
  73. echo "no errors";
  74. #replace manual line returns in e-mail field
  75. $email = preg_replace("([\r\n])", "", $email);
  76.  
  77. #prevent BCC
  78. $find = "[content-type|Content-Type|bcc:|cc:|viagra|levitra|pariscialis|angelfire|freewebpages|xxx|gay|sluts|incest|hardcore|anal]";
  79. #$find2 = "[http:]";
  80. if (preg_match($find, $insuredName) || preg_match($find, $email) || preg_match($find, $phone) || preg_match($find, $city) || preg_match($find, $state) || preg_match($find, $zip)) {
  81. print("<p>No meta/header injections, please. E-mail will not be sent.</p>");
  82. exit;
  83. }
  84. //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  85. require_once('class.phpmailer.php');
  86.  
  87. $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  88.  
  89. $mail->IsSMTP(); // telling the class to use SMTP
  90.  
  91. try {
  92. $mail->Host = "172.16.4.18"; // SMTP server
  93. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  94. $mail->AddReplyTo('name@yourdomain.com', 'First Last');
  95. $mail->AddAddress('DPolletta@mbcinteractive.com' , 'Don Polletta', 'teresa.romano@nc.rr.com' , 'Teresa J Romano');
  96. $mail->SetFrom('"' . stripslashes(checkit($_POST['insuredName'])) . '" <' . stripslashes(checkit($_POST['email'])) . '>');
  97. $mail->Subject = 'Auto Insurance Quote Request from the Tracy-Driscoll web site';
  98. $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  99. $message->setBody=(to $mail->msgHTML(
  100.  
  101. 'Received On: '.date('m/d/Y H:i:s').'\n\r
  102.  
  103. Insured Information\n'.
  104.  
  105. 'Name: ' . stripslashes(checkit($_POST['$insuredName'])) . '\n'.
  106. 'Address: $address\n'.
  107. 'City: $city\n'.
  108. 'State: $state\n'.
  109. 'Zip: $zip\n'.
  110. 'Phone: $phone\n'.
  111. 'Email: $email\n'.
  112. 'Date of Birth: $dobMonth'/'$dobDay'/'$dobYear\n'.
  113. 'Drivers License Number: $driversLicense\n'.
  114.  
  115. 'Current Insurance\n\r'.
  116.  
  117. 'Do you have Insurance: $do_you\n\r'.
  118.  
  119. 'Coverages\n\r'.
  120.  
  121. 'Bodily Injury Liability: $bodilyInjury\n'.
  122. 'Property Damage Liability: $propertyDamage\n'.
  123. 'Medical Payments: $medicalPayments\n'.
  124. 'Comprehensive Deductible: $comprehensiveDeductible\n'.
  125. 'Collision Deductible: $collisionDeductible\n'.
  126. 'Rental Reimbursement: $rentalReimbursement\n' .
  127. 'Towing & Labor: $towing\n\r'.
  128.  
  129. 'Vehicle 1 Information:\n'.
  130. 'Year: $v1year\n'.
  131. 'Make & Model: $v1make\n'.
  132. ' VIN: $v1vin\n\r'.
  133.  
  134. 'Vehicle 2 Information:\n'.
  135. ' Year: $v2year\n'.
  136. ' Make & Model: $v2make\n'.
  137. ' VIN: $v2vin\n\r'.
  138.  
  139. 'Licensed Drivers:\n\r'.
  140.  
  141. 'Any other Drivers: $otherDrivers\n'.
  142. 'How Many?: $howMany\n\r'.
  143.  
  144. 'Credit Check\n\r'.
  145.  
  146. 'Permission: $permission\n'.
  147. 'SSN: $ssn');
  148.  
  149.  
  150. $mail->Send();
  151.  
  152. echo "Message Sent OK</p>\n";
  153.  
  154. }
  155.  
  156. catch (phpmailerException $e)
  157. {
  158. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  159. }
  160. catch (Exception $e)
  161. {
  162. echo $e->getMessage(); //Boring error messages from anything else!
  163. }
  164.  
  165. $mail->Host = "172.16.4.18"; // SMTP server
  166. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  167. $mail->AddReplyTo('name@yourdomain.com', 'First Last');
  168. $mail->AddAddress('DPolletta@mbcinteractive.com' , 'Don Polletta', 'teresa.romano@nc.rr.com' , 'Teresa J Romano');
  169. $mail->SetFrom('"' . stripslashes(checkit($_POST['insuredName'])) . '" <' . stripslashes(checkit($_POST['email'])) . '>');
  170. $mail->Subject = 'Auto Insurance Quote Request from the Tracy-Driscoll web site';
  171. $mail->AltBody =
  172.  
  173. 'Hello '.$_POST['$insuredName'].',\n'.
  174. 'Your quote request has been received! This email is a confirmation that we have received your request and is now being processed. You will be contacted by phone or email to discuss your Automobile Insurance Options.\n\r'.
  175.  
  176. 'For more exciting offers and news, please join our email list or become our fan on Facebook. Thank you for choosing Tracy-Driscoll for your Automobile Insurance Needs.\n\r'.
  177. 'Thank you,\n'.
  178. 'Tracy Driscoll');
  179.  
  180. $mail->Send();
  181.  
  182. echo "Message Sent OK</p>\n";
  183.  
  184. }
  185.  
  186. catch (phpmailerException $e)
  187. {
  188. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  189. }
  190. catch (Exception $e)
  191. {
  192. echo $e->getMessage(); //Boring error messages from anything else!
  193. }
  194.  
  195. //header("Location: thankyou.php?n=".$insuredName."&date=");
  196. exit();
  197. }else{
  198. echo "you have errors!<br />";
  199. print_r($errorFields);
  200. }
  201. }else{
  202. // need to show the form here.. or just re-direct back to the form.
  203. header("Location: http://www.tracy-driscoll.com/landingpages/auto/autoquote2.html");
  204. }
  205.  
  206. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement