Advertisement
towfiqi

autoresponder.php

Sep 6th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. function optimizer_send_message($to) {
  2.  
  3. if (isset($_POST['contact_message'])) {
  4. add_filter('wp_mail_content_type', 'optimizer_contact_mail_type' );
  5. $to = optimizer_contact_widget_email();
  6. $to = explode(",",$to);
  7.  
  8. $subject = get_bloginfo('name')." | ". esc_html($_POST['contact_subject']);
  9. if (isset($_POST['contact_extra'])) {$extra_field = ' / '.esc_html($_POST['contact_extra']); }else{$extra_field = '';}
  10.  
  11.  
  12. ob_start();
  13. echo '<p style="border-bottom: 1px solid #DADADA;padding-bottom: 15px;"><b>From:</b> '.esc_html($_POST['contact_name']).' / '.sanitize_email($_POST['contact_email']).''.$extra_field.' <br></p>';
  14. echo wp_kses(wpautop($_POST['contact_message']));
  15.  
  16. $message = ob_get_contents();
  17.  
  18. ob_end_clean();
  19.  
  20. //$mail = wp_mail($to, $subject, $message, $headers);
  21. foreach($to as $email_address)
  22. {
  23. $headers = "From: ".sanitize_email($email_address)." <".sanitize_email($email_address).">\r\nReply-To:".sanitize_email($_POST['contact_email']);
  24. wp_mail($email_address, $subject, $message, $headers);
  25. }
  26.  
  27.  
  28. //Auto Responder
  29. $responder_subject = 'RE:'. $subject;
  30. $responder_email = sanitize_email($_POST['contact_email']);
  31. $responder_headers = "From: ".sanitize_email($to[0])." <".sanitize_email($to[0]).">\r\nReply-To:".sanitize_email($to[0]);
  32.  
  33. ob_start();
  34. $respmsg = "<p>Hi,</p><p>Thanks for getting in Touch. We will get back to you within 3 Business Days!</p><p>Yours Sincerly</p>";
  35. echo wp_kses(wpautop($respmsg));
  36.  
  37. $responder_message = ob_get_contents();
  38.  
  39. ob_end_clean();
  40.  
  41.  
  42. wp_mail($responder_email, $responder_subject, $responder_message, $responder_headers);
  43.  
  44. //if($mail){
  45. echo 'success';
  46. //}
  47. remove_filter('wp_mail_content_type', 'optimizer_contact_mail_type' );
  48. }
  49.  
  50. exit();
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement