Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function optimizer_send_message($to) {
- if (isset($_POST['contact_message'])) {
- add_filter('wp_mail_content_type', 'optimizer_contact_mail_type' );
- $to = optimizer_contact_widget_email();
- $to = explode(",",$to);
- $subject = get_bloginfo('name')." | ". esc_html($_POST['contact_subject']);
- if (isset($_POST['contact_extra'])) {$extra_field = ' / '.esc_html($_POST['contact_extra']); }else{$extra_field = '';}
- ob_start();
- 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>';
- echo wp_kses(wpautop($_POST['contact_message']));
- $message = ob_get_contents();
- ob_end_clean();
- //$mail = wp_mail($to, $subject, $message, $headers);
- foreach($to as $email_address)
- {
- $headers = "From: ".sanitize_email($email_address)." <".sanitize_email($email_address).">\r\nReply-To:".sanitize_email($_POST['contact_email']);
- wp_mail($email_address, $subject, $message, $headers);
- }
- //Auto Responder
- $responder_subject = 'RE:'. $subject;
- $responder_email = sanitize_email($_POST['contact_email']);
- $responder_headers = "From: ".sanitize_email($to[0])." <".sanitize_email($to[0]).">\r\nReply-To:".sanitize_email($to[0]);
- ob_start();
- $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>";
- echo wp_kses(wpautop($respmsg));
- $responder_message = ob_get_contents();
- ob_end_clean();
- wp_mail($responder_email, $responder_subject, $responder_message, $responder_headers);
- //if($mail){
- echo 'success';
- //}
- remove_filter('wp_mail_content_type', 'optimizer_contact_mail_type' );
- }
- exit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement