1. <?php
  2.  
  3. $mailto = "info@tdmtransport.com";
  4. $subject = "Inquiry";
  5. $formurl = "http://www.tdmtransport.com/contact.html";
  6. $errorurl = "http://www.tdmtransport.com/error.html";
  7. $thankyouurl = "http://www.tdmtransport.com/thanks.html";
  8.  
  9. $email_is_required = 1;
  10. $name_is_required = 1;
  11. $comments_is_required = 0;
  12. $uself = 0;
  13. $use_envsender = 0;
  14. $use_sendmailfrom = 0;
  15. $use_webmaster_email_for_from = 0;
  16. $use_utf8 = 1;
  17. $my_recaptcha_private_key = '' ;
  18.  
  19. // -------------------- END OF CONFIGURABLE SECTION ---------------
  20.  
  21. $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
  22. $content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
  23. if (!isset( $use_envsender )) { $use_envsender = 0 ; }
  24. if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {
  25. ini_set( 'sendmail_from', $mailto );
  26. }
  27. $envsender = "-f$mailto" ;
  28. $first_name = $_POST['first_name']; // required
  29. $last_name = $_POST['last_name']; // required
  30. $company = $_POST['company']; // required
  31. $email_from = $_POST['email']; // required
  32. $phone = $_POST['phone']; // required
  33. $comodity = $_POST['comodity']; //required
  34. $truckload_or_ltl = $_POST['truckload_or_ltl']; //required
  35. $weight = $_POST['weight']; //required
  36. $trailer = $_POST['trailer']; //required
  37. $tarp = $_POST['tarp']; //not required
  38. $length_width_height = $_POST['length_width_height']; //not required
  39. $comments = $_POST['comments']; // not required
  40. $http_referrer = getenv( "HTTP_REFERER" );
  41.  
  42. if (!isset($_POST['email'])) {
  43. header( "Location: $formurl" );
  44. exit ;
  45. }
  46. if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {
  47. header( "Location: $errorurl" );
  48. exit ;
  49. }
  50. if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {
  51. header( "Location: $errorurl" );
  52. exit ;
  53. }
  54. if (strlen( $my_recaptcha_private_key )) {
  55. require_once( 'recaptchalib.php' );
  56. $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
  57. if (!$resp->is_valid) {
  58. header( "Location: $errorurl" );
  59. exit ;
  60. }
  61. }
  62. if (empty($email)) {
  63. $email = $mailto ;
  64. }
  65. $fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;
  66.  
  67. if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
  68. $comments = stripslashes( $comments );
  69. }
  70.  
  71. $messageproper =
  72. "This message was sent from:\n" .
  73. "$http_referrer\n" .
  74. "------------------------------------------------------------\n" .
  75. "Name of sender: $fullname\n" .
  76. "Email of sender: $email\n" .
  77. "------------------------- COMMENTS -------------------------\n\n" .
  78. $comments .
  79. "\n\n------------------------------------------------------------\n" ;
  80.  
  81. $headers =
  82. "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" .
  83. $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
  84.  
  85. if ($use_envsender) {
  86. mail($mailto, $subject, $messageproper, $headers, $envsender );
  87. }
  88. else {
  89. mail($mailto, $subject, $messageproper, $headers );
  90. }
  91. header( "Location: $thankyouurl" );
  92. exit ;
  93.  
  94. ?>