form.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. date_default_timezone_set("Australia/Hobart");
  3. $datetime = date("D dS M y @ h:i a");
  4. //error_reporting(E_ALL);
  5. //ini_set('display_errors', 1);
  6. error_reporting(E_ERROR | E_PARSE);
  7. /*
  8. * PHPMailer simple contact form example.
  9. * If you want to accept and send uploads in your form, look at the send_file_upload example.
  10. */
  11. //Import the PHPMailer class into the global namespace
  12. use PHPMailer\PHPMailer\PHPMailer;
  13. use PHPMailer\PHPMailer\SMTP;
  14. use PHPMailer\PHPMailer\Exception;
  15. require 'phpmailer/src/Exception.php';
  16. require 'phpmailer/src/PHPMailer.php';
  17. require 'phpmailer/src/SMTP.php';
  18. if (array_key_exists('email', $_POST)) {
  19. $err = false;
  20. $msg = '';
  21. $email = '';
  22. //Apply some basic validation and filtering to the subject
  23. if (array_key_exists('subject', $_POST)) {
  24. $subject = substr(strip_tags($_POST['subject']), 0, 255);
  25. } else {
  26. $subject = 'No subject given';
  27. }
  28. //Apply some basic validation and filtering to the query
  29. if (array_key_exists('query', $_POST)) {
  30. //Limit length and strip HTML tags
  31. $query = substr(strip_tags($_POST['query']), 0, 16384);
  32. } else {
  33. $query = '';
  34. $msg = 'No query provided!';
  35. $err = true;
  36. }
  37. //Apply some basic validation and filtering to the name
  38. if (array_key_exists('name', $_POST)) {
  39. //Limit length and strip HTML tags
  40. $name = substr(strip_tags($_POST['name']), 0, 255);
  41. } else {
  42. $name = '';
  43. }
  44. //Apply some basic validation and filtering to the name
  45. if (array_key_exists('mobile', $_POST)) {
  46. //Limit length and strip HTML tags
  47. $mobile = substr(strip_tags($_POST['mobile']), 0, 255);
  48. } else {
  49. $mobile = '';
  50. }
  51. //Apply some basic validation and filtering to the name
  52. if (array_key_exists('property_address', $_POST)) {
  53. //Limit length and strip HTML tags
  54. $property_address = substr(strip_tags($_POST['property_address']), 0, 255);
  55. } else {
  56. $property_address = '';
  57. }
  58. //Make sure the address they provided is valid before trying to use it
  59. if (array_key_exists('email', $_POST) && PHPMailer::validateAddress($_POST['email'])) {
  60. $email = $_POST['email'];
  61. } else {
  62. $msg .= 'Error: invalid email address provided';
  63. $err = true;
  64. }
  65. if (!$err) {
  66. $mail = new PHPMailer();
  67. //$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->SMTPDebug = SMTP::DEBUG_SERVER;
  68. $mail->isSMTP();
  69. $mail->Host = 'mail.tazz.com.au';
  70. $mail->SMTPAuth = true;
  71. $mail->Username = 'itadmin@tazz.com.au';
  72. $mail->Password = 'e]GG%LI,6$cx';
  73. $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
  74. $mail->Port = 465;
  75. $mail->CharSet = PHPMailer::CHARSET_UTF8;
  76. //It's important not to use the submitter's address as the from address as it's forgery,
  77. //which will cause your messages to fail SPF checks.
  78. //Use an address in your own domain as the from address, put the submitter's address in a reply-to
  79. $mail->setFrom('ben@tazz.com.au', (empty($name) ? 'Contact form' : $name));
  80. $mail->addAddress('ben@tazz.com.au');
  81. $mail->addReplyTo($email, $name);
  82. //Attachments
  83. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
  84. //Content
  85. $mail->isHTML(true); //Set email format to HTML
  86. $mail->Subject = 'Contact form: ' . $subject;
  87. $message = '<html><body>';
  88. $message .= '<h2><b>' . $subject . ' Contact Enquiry from</b></h2><br>';
  89. $message .= '<p>Name: <b>' . $name . '</b></p>';
  90. $message .= '<p>Email Address: <b>' . $email . '</b></p>';
  91. $message .= '<p>Mobile Number: <b>' . $mobile . '</b></p>';
  92. $message .= '<p>Property Address: <b>' . $property_address . '</b></p>';
  93. $message .= '<p>Enquiry:<br>' . $query . '</p><br><br>';
  94. $message .= $datetime . '<br><br>';
  95. $message .= '<span style="font-weight:bold; font-size: 12px color:#635A4A;">' . $name . '</span><br><span style="color:#D82508;font-size: 11px">Blueprint Sudio</span><br>';
  96. $message .= '<br><span style="font-family: arial; color: #635A4A; font-size: 12px">Blueprint Sudio | 34 Coplestone Street | Scottsdale | Tas | 7260</span><br>';
  97. $message .= '<span style="font-family: arial; color: #635A4A; font-size: 11px;"><b>M</b> 0402 984 082<b> | E</b> design@studioblueprint.com.au<b> | W</b> studioblueprint.com.au</span><br><br>';
  98. $message .= '<a href="https://studioblueprint.com.au"><img style="max-width: 250px; height: auto;" src="https://studioblueprint.com.au/internal/images/blueprint-full-logo-medium.png" alt="Blueprint Sudio" title="Blueprint Sudio"></a><br><br>';
  99. $message .= '<br><br><span style="font-family: arial; color: lightgrey; font-size: 9px;">Blueprint Sudio Legal Disclaimer: This email is confidential and may contain legally privileged information. If you are not the intended recipient , you must not disclose or use the information contained in it. If you have received this email in error, please notify us immediately by return email and delete the document.</span></p>';
  100. $message .= '</body></html>';
  101. $mail->Body = $message;
  102. if (!$mail->send()) {
  103. $msg .= 'Mailer Error: ' . $mail->ErrorInfo;
  104. } else {
  105. $msg .= 'Message sent!';
  106. }
  107. }
  108. } ?>