Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. require 'phpmailer/PHPMailerAutoload.php';
  2. $feedback='';
  3. $flag = array();
  4. if(isset($_POST["submitlogin"]) and $_SERVER['REQUEST_METHOD'] == "POST"){
  5.  
  6. $name = seo_friendly_url($_POST['name']);
  7. $email = seo_friendly_url($_POST['email']);
  8. $subject = seo_friendly_url($_POST['subject']);
  9. $message = seo_friendly_url($_POST['message']);
  10.  
  11. //Email
  12.  
  13. if (!preg_match("/([w-]+@[w-]+.[w-]+)/",$email)) {
  14. $feedback="Invalid email format";
  15. array_push($flag,"false");
  16. }else {
  17. array_push($flag,"true");
  18. }
  19. //Email
  20.  
  21. //Name
  22. if (preg_match('/^[-a-zA-Z0-9._]+$/', $name)){
  23. array_push($flag,"true");
  24. }else {
  25. $feedback="Invalid name format";
  26. array_push($flag,"false");
  27. }
  28. //Name
  29.  
  30.  
  31. if (!in_array("false", $flag)) {
  32.  
  33. //SMTP needs accurate times, and the PHP time zone MUST be set
  34. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  35. date_default_timezone_set('Etc/UTC');
  36.  
  37. //Create a new PHPMailer instance
  38. $mail = new PHPMailer;
  39. //Tell PHPMailer to use SMTP
  40. $mail->isSMTP();
  41. //Enable SMTP debugging
  42. // 0 = off (for production use)
  43. // 1 = client messages
  44. // 2 = client and server messages
  45. $mail->SMTPDebug = 2;
  46. //Ask for HTML-friendly debug output
  47. $mail->Debugoutput = 'html';
  48. //Set the hostname of the mail server
  49. $mail->Host = "smtpout.asia.secureserver.net";
  50. //Set the SMTP port number - likely to be 25, 465 or 587
  51. $mail->Port = 25;
  52. //Whether to use SMTP authentication
  53. //$mail->Username = 'email@email.com';
  54. //$mail->Password = 'password';
  55. $mail->SMTPAuth = false;
  56. //Set who the message is to be sent from
  57. $mail->setFrom('email@email.com');
  58. //Set an alternative reply-to address
  59. $mail->addReplyTo($email);
  60. //Set who the message is to be sent to
  61. $mail->addAddress('email@email.com'); // Add a recipient
  62. $mail->addAddress('email@email.com');
  63. $mail->addAddress('email@email.com);
  64. //Set the subject line
  65. $mail->Subject = 'HLS Inquiry';
  66. //Read an HTML message body from an external file, convert referenced images to embedded,
  67. //convert HTML into a basic plain-text alternative body
  68. $mail->msgHTML($message);
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. $email_ar = $email;
  77. $subject_ar = $name.", Thank you for your Inquiry";
  78. $acknowledgement_receipt = '
  79. <div style="padding:10px 20px;font-size:16px;">
  80.  
  81. <p>Dear '.$name.',</p>
  82.  
  83. <p>We&#39;ve received your message and would like to thank you for contacting us. We will reply by email shortly.</p>
  84.  
  85. <p>Talk to you soon,</p>
  86.  
  87. <p>
  88. <div>Customer Service</div>
  89.  
  90. </p>
  91.  
  92. </div>
  93. ';
  94.  
  95.  
  96.  
  97. if ($mail->send()) {
  98. $feedback = "<span style='color:green;'>Thank you for your inquiry. We will respond to you within 24 hours.</span>";
  99. }
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement