function cntctfrm_send_mail() { global $cntctfrm_options, $path_of_uploaded_file, $wp_version, $wpdb; $to = $headers = ""; $lang = isset($_POST['cntctfrm_language']) ? $_POST['cntctfrm_language'] : 'en'; $name = isset($_POST['cntctfrm_contact_name']) ? $_POST['cntctfrm_contact_name'] : ""; $address = isset($_POST['cntctfrm_contact_address']) ? $_POST['cntctfrm_contact_address'] : ""; $email = isset($_POST['cntctfrm_contact_email']) ? stripslashes($_POST['cntctfrm_contact_email']) : ""; $subject = isset($_POST['cntctfrm_contact_subject']) ? $_POST['cntctfrm_contact_subject'] : ""; $message = isset($_POST['cntctfrm_contact_message']) ? $_POST['cntctfrm_contact_message'] : ""; $phone = isset($_POST['cntctfrm_contact_phone']) ? $_POST['cntctfrm_contact_phone'] : ""; $user_agent = cntctfrm_clean_input($_SERVER['HTTP_USER_AGENT']); $name = stripslashes(strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $name)))); $address = stripslashes(strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $address)))); $email = stripslashes(strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $email)))); $subject = stripslashes(strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $subject)))); $message = stripslashes(strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $message)))); $phone = stripslashes(strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $phone)))); if (isset($_SESSION['cntctfrm_send_mail']) && true == $_SESSION['cntctfrm_send_mail']) { return true; } if ('user' == $cntctfrm_options['cntctfrm_select_email']) { if ('3.3' > $wp_version && function_exists('get_userdatabylogin') && false !== ($user = get_userdatabylogin($cntctfrm_options['cntctfrm_user_email']))) { $to = $user->user_email; } elseif (false !== ($user = get_user_by('login', $cntctfrm_options['cntctfrm_user_email']))) { $to = $user->user_email; } } else { $to = $cntctfrm_options['cntctfrm_custom_email']; } if ("" == $to) { /* If email options are not certain choose admin email */ $to = get_option("admin_email"); } if ("" != $to) { $user_info_string = $userdomain = $form_action_url = ''; $attachments = array(); if ('on' == strtolower(getenv('HTTPS'))) { $form_action_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } else { $form_action_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } if (1 == $cntctfrm_options['cntctfrm_display_add_info']) { $userdomain = @gethostbyaddr($_SERVER['REMOTE_ADDR']); if (1 == $cntctfrm_options['cntctfrm_display_add_info'] || 1 == $cntctfrm_options['cntctfrm_display_sent_from'] || 1 == $cntctfrm_options['cntctfrm_display_coming_from'] || 1 == $cntctfrm_options['cntctfrm_display_user_agent']) { if (1 == $cntctfrm_options['cntctfrm_html_email']) { $user_info_string .= '<tr><td><br /></td><td><br /></td></tr>'; } } if (1 == $cntctfrm_options['cntctfrm_display_sent_from']) { if (1 == $cntctfrm_options['cntctfrm_html_email']) { $user_info_string .= '<tr><td>' . __('Sent from (ip address)', 'contact_form') . ':</td><td>' . $_SERVER['REMOTE_ADDR'] . " ( " . $userdomain . " )" . '</td></tr>'; } else { $user_info_string .= __('Sent from (ip address)', 'contact_form') . ': ' . $_SERVER['REMOTE_ADDR'] . " ( " . $userdomain . " )" . "\n"; } } if (1 == $cntctfrm_options['cntctfrm_display_date_time']) { if (1 == $cntctfrm_options['cntctfrm_html_email']) { $user_info_string .= '<tr><td>' . __('Date/Time', 'contact_form') . ':</td><td>' . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime(current_time('mysql'))) . '</td></tr>'; } else { $user_info_string .= __('Date/Time', 'contact_form') . ': ' . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime(current_time('mysql'))) . "\n"; } } if (1 == $cntctfrm_options['cntctfrm_display_coming_from']) { if (1 == $cntctfrm_options['cntctfrm_html_email']) { $user_info_string .= '<tr><td>' . __('Sent from (referer)', 'contact_form') . ':</td><td>' . $form_action_url . '</td></tr>'; } else { $user_info_string .= __('Sent from (referer)', 'contact_form') . ': ' . $form_action_url . "\n"; } } if (1 == $cntctfrm_options['cntctfrm_display_user_agent']) { if (1 == $cntctfrm_options['cntctfrm_html_email']) { $user_info_string .= '<tr><td>' . __('Using (user agent)', 'contact_form') . ':</td><td>' . $user_agent . '</td></tr>'; } else { $user_info_string .= __('Using (user agent)', 'contact_form') . ': ' . $user_agent . "\n"; } } } /* Message */ if (1 == $cntctfrm_options['cntctfrm_html_email']) { $message_text = '<html> <head> <title>' . __("Contact from", 'contact_form') . ' ' . get_bloginfo('name') . '</title> </head> <body> <table>'; if (1 == $cntctfrm_options['cntctfrm_display_name_field']) { $message_text .= '<tr><td width="160">'; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_name_label'][$lang] : __("Name", 'contact_form'); $message_text .= '</td><td>' . $name . '</td></tr>'; } if (1 == $cntctfrm_options['cntctfrm_display_address_field']) { $message_text .= '<tr><td>'; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_address_label'][$lang] : __("Address", 'contact_form'); $message_text .= '</td><td>' . $address . '</td></tr>'; } $message_text .= '<tr><td>'; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_email_label'][$lang] : __("Email", 'contact_form'); $message_text .= '</td><td>' . $email . '</td></tr>'; if (1 == $cntctfrm_options['cntctfrm_display_phone_field']) { $message_text .= '<tr><td>'; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_phone_label'][$lang] : __("Phone", 'contact_form'); $message_text .= '</td><td>' . $phone . '</td></tr>'; } $message_text .= '<tr><td>'; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_subject_label'][$lang] : __("Subject", 'contact_form'); $message_text .= '</td><td>' . $subject . '</td></tr> <tr><td>'; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_message_label'][$lang] : __("Message", 'contact_form'); $message_text .= '</td><td>' . $message . '</td> </tr> <tr><td>' . __("Site", 'contact_form') . '</td><td>' . get_bloginfo("url") . '</td></tr> <tr> <td><br /></td><td><br /></td> </tr>'; $message_text_for_user = $message_text . '</table></body></html>'; $message_text .= $user_info_string . '</table></body></html>'; } else { $message_text = ''; if (1 == $cntctfrm_options['cntctfrm_display_name_field']) { $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_name_label'][$lang] : __("Name", 'contact_form'); $message_text .= ': ' . $name . "\n"; } if (1 == $cntctfrm_options['cntctfrm_display_address_field']) { $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_address_label'][$lang] : __("Address", 'contact_form'); $message_text .= ': ' . $address . "\n"; } $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_email_label'][$lang] : __("Email", 'contact_form'); $message_text .= ': ' . $email . "\n"; if (1 == $cntctfrm_options['cntctfrm_display_phone_field']) { $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_phone_label'][$lang] : __("Phone", 'contact_form'); $message_text .= ': ' . $phone . "\n"; } $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_subject_label'][$lang] : __("Subject", 'contact_form'); $message_text .= ': ' . $subject . "\n"; $message_text .= 1 == $cntctfrm_options['cntctfrm_change_label_in_email'] ? $cntctfrm_options['cntctfrm_message_label'][$lang] : __("Message", 'contact_form'); $message_text .= ': ' . $message . "\n" . __("Site", 'contact_form') . ': ' . get_bloginfo("url") . "\n" . "\n"; $message_text_for_user = $message_text; $message_text .= $user_info_string; } do_action('cntctfrm_get_mail_data', $to, $name, $email, $address, $phone, $subject, $message, $form_action_url, $user_agent, $userdomain); if (!function_exists('is_plugin_active')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } /* 'from' name */ $from_field_name = 'custom' == $cntctfrm_options['cntctfrm_select_from_field'] ? stripslashes($cntctfrm_options['cntctfrm_from_field']) : $name; /* 'from' email */ $from_email = 'custom' == $cntctfrm_options['cntctfrm_from_email'] ? stripslashes($cntctfrm_options['cntctfrm_custom_from_email']) : stripslashes($email); if ((is_plugin_active('email-queue/email-queue.php') || is_plugin_active('email-queue-pro/email-queue-pro.php')) && function_exists('mlq_if_mail_plugin_is_in_queue') && mlq_if_mail_plugin_is_in_queue(plugin_basename(__FILE__))) { /* if email-queue plugin is active and this plugin's "in_queue" status is 'ON' */ /* attachment path */ $attachment_file = 1 == $cntctfrm_options['cntctfrm_attachment'] && isset($_FILES["cntctfrm_contact_attachment"]["tmp_name"]) && "" != $_FILES["cntctfrm_contact_attachment"]["tmp_name"] ? $path_of_uploaded_file : ''; /* headers */ /* content type */ $headers .= 1 == $cntctfrm_options['cntctfrm_html_email'] ? 'Content-type: text/html; charset=utf-8' . "\n" : 'Content-type: text/plain; charset=utf-8' . "\n"; /* 'from' name & email */ $headers .= 'From: ' . $from_field_name . ' <' . $from_email . '>'; /* send copy */ if (isset($_POST['cntctfrm_contact_send_copy']) && 1 == $_POST['cntctfrm_contact_send_copy']) { do_action('cntctfrm_get_mail_data_for_mlq', plugin_basename(__FILE__), $email, $subject, $message_text_for_user, $attachment_file, $headers); } global $mlq_mail_result; do_action('cntctfrm_get_mail_data_for_mlq', plugin_basename(__FILE__), $to, $subject, $message_text, $attachment_file, $headers); /* return $mail_result = true if email-queue has successfully inserted mail in its DB; in other case - return false */ return $mail_result = $mlq_mail_result; } else { if ('wp-mail' == $cntctfrm_options['cntctfrm_mail_method']) { /* To send HTML mail, the Content-type header must be set */ if (1 == $cntctfrm_options['cntctfrm_html_email']) { $headers .= 'Content-type: text/html; charset=utf-8' . "\n"; } else { $headers .= 'Content-type: text/plain; charset=utf-8' . "\n"; } /* Additional headers */ $headers .= 'From: ' . $from_field_name . ' <' . $from_email . '>'; if (1 == $cntctfrm_options['cntctfrm_attachment'] && isset($_FILES["cntctfrm_contact_attachment"]["tmp_name"]) && "" != $_FILES["cntctfrm_contact_attachment"]["tmp_name"]) { $path_parts = pathinfo($path_of_uploaded_file); $path_of_uploaded_file_changed = $path_parts['dirname'] . '/' . preg_replace('/^cntctfrm_[A-Z,a-z,0-9]{32}_/i', '', $path_parts['basename']); if (!@copy($path_of_uploaded_file, $path_of_uploaded_file_changed)) { $path_of_uploaded_file_changed = $path_of_uploaded_file; } $attachments = array($path_of_uploaded_file_changed); } if (isset($_POST['cntctfrm_contact_send_copy']) && 1 == $_POST['cntctfrm_contact_send_copy']) { wp_mail($email, $subject, $message_text_for_user, $headers, $attachments); } /* Mail it */ $mail_result = wp_mail($to, $subject, $message_text, $headers, $attachments); /* Delete attachment */ if (1 == $cntctfrm_options['cntctfrm_attachment'] && isset($_FILES["cntctfrm_contact_attachment"]["tmp_name"]) && "" != $_FILES["cntctfrm_contact_attachment"]["tmp_name"] && $path_of_uploaded_file_changed != $path_of_uploaded_file) { @unlink($path_of_uploaded_file_changed); } if (1 == $cntctfrm_options['cntctfrm_attachment'] && isset($_FILES["cntctfrm_contact_attachment"]["tmp_name"]) && "" != $_FILES["cntctfrm_contact_attachment"]["tmp_name"] && '1' == $cntctfrm_options['cntctfrm_delete_attached_file']) { @unlink($path_of_uploaded_file); } return $mail_result; } else { /* Set headers */ $headers .= 'MIME-Version: 1.0' . "\n"; if (1 == $cntctfrm_options['cntctfrm_attachment'] && isset($_FILES["cntctfrm_contact_attachment"]["tmp_name"]) && "" != $_FILES["cntctfrm_contact_attachment"]["tmp_name"]) { $message_block = $message_text; $message_block_for_user = $message_text_for_user; /* Additional headers */ $headers .= 'From: ' . $from_field_name . ' <' . $from_email . '>' . "\n"; $bound_text = "jimmyP123"; $bound = "--" . $bound_text . ""; $bound_last = "--" . $bound_text . "--"; $headers .= "Content-Type: multipart/mixed; boundary=\"{$bound_text}\""; $message_text = $message_text_for_user = __("If you can see this MIME, it means that the MIME type is not supported by your email client!", "contact_form") . "\n"; if (1 == $cntctfrm_options['cntctfrm_html_email']) { $message_text .= $bound . "\n" . "Content-Type: text/html; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message_block . "\n\n"; $message_text_for_user .= $bound . "\n" . "Content-Type: text/html; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message_block_for_user . "\n\n"; } else { $message_text .= $bound . "\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message_block . "\n\n"; $message_text_for_user .= $bound . "\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message_block_for_user . "\n\n"; } $file = file_get_contents($path_of_uploaded_file); $message_text .= $bound . "\n" . "Content-Type: application/octet-stream; name=\"" . $_FILES["cntctfrm_contact_attachment"]["name"] . "\"\n" . "Content-Description: " . basename($path_of_uploaded_file) . "\n" . "Content-Disposition: attachment;\n" . " filename=\"" . $_FILES["cntctfrm_contact_attachment"]["name"] . "\"; size=" . filesize($path_of_uploaded_file) . ";\n" . "Content-Transfer-Encoding: base64\n\n" . chunk_split(base64_encode($file)) . "\n\n" . $bound_last; $message_text_for_user .= $bound . "\n" . "Content-Type: application/octet-stream; name=\"" . $_FILES["cntctfrm_contact_attachment"]["name"] . "\"\n" . "Content-Description: " . basename($path_of_uploaded_file) . "\n" . "Content-Disposition: attachment;\n" . " filename=\"" . $_FILES["cntctfrm_contact_attachment"]["name"] . "\"; size=" . filesize($path_of_uploaded_file) . ";\n" . "Content-Transfer-Encoding: base64\n\n" . chunk_split(base64_encode($file)) . "\n\n" . $bound_last; } else { /* To send HTML mail, header must be set */ if (1 == $cntctfrm_options['cntctfrm_html_email']) { $headers .= 'Content-type: text/html; charset=utf-8' . "\n"; } else { $headers .= 'Content-type: text/plain; charset=utf-8' . "\n"; } /* Additional headers */ $headers .= 'From: ' . $from_field_name . ' <' . $from_email . '>' . "\n"; } if (isset($_POST['cntctfrm_contact_send_copy']) && 1 == $_POST['cntctfrm_contact_send_copy']) { @mail($email, $subject, $message_text_for_user, $headers); } $mail_result = @mail($to, $subject, $message_text, $headers); /* Delete attachment */ if (1 == $cntctfrm_options['cntctfrm_attachment'] && isset($_FILES["cntctfrm_contact_attachment"]["tmp_name"]) && "" != $_FILES["cntctfrm_contact_attachment"]["tmp_name"] && '1' == $cntctfrm_options['cntctfrm_delete_attached_file']) { @unlink($path_of_uploaded_file); } return $mail_result; } } } return false; }
function sbscrbr_sent_unsubscribe_mail($email) { global $wpdb, $sbscrbr_options, $sbscrbr_send_unsubscribe_mail; $sbscrbr_send_unsubscribe_mail = ""; if (empty($sbscrbr_options)) { $sbscrbr_options = is_multisite() ? get_site_option('sbscrbr_options') : get_option('sbscrbr_options'); } $prefix = is_multisite() ? $wpdb->base_prefix : $wpdb->prefix; $report = array('done' => false, 'error' => false); $user_info = $wpdb->get_row("SELECT `id_user`, `user_display_name`, `unsubscribe_code` FROM `" . $prefix . "sndr_mail_users_info` WHERE `user_email`='" . $email . "'", ARRAY_A); if (empty($user_info)) { $report['error'] = $sbscrbr_options['cannot_get_email']; } else { $from_name = empty($sbscrbr_options['from_custom_name']) ? get_bloginfo('name') : $sbscrbr_options['from_custom_name']; if (empty($sbscrbr_options['from_email'])) { $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } $from_email = 'wordpress@' . $sitename; } else { $from_email = $sbscrbr_options['from_email']; } $headers = 'From: ' . $from_name . ' <' . $from_email . '>'; $subject = $sbscrbr_options['unsubscribe_message_subject']; $message = sbscrbr_replace_shortcodes($sbscrbr_options['unsubscribe_message_text'], $email); if (!function_exists('is_plugin_active')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if ((is_plugin_active('email-queue/email-queue.php') || is_plugin_active('email-queue-pro/email-queue-pro.php')) && function_exists('mlq_if_mail_plugin_is_in_queue') && mlq_if_mail_plugin_is_in_queue(plugin_basename(__FILE__))) { /* if email-queue plugin is active and this plugin's "in_queue" status is 'ON' */ global $mlq_mail_result, $mlqpr_mail_result; do_action('sbscrbr_get_mail_data', plugin_basename(__FILE__), $email, $subject, $message, $headers); if ($mlq_mail_result || $mlqpr_mail_result) { $sbscrbr_send_unsubscribe_mail = true; $report['done'] = 'check mail'; } else { $report['error'] = $sbscrbr_options['cannot_send_email']; } } else { if (wp_mail($email, $subject, $message, $headers)) { $sbscrbr_send_unsubscribe_mail = true; $report['done'] = 'check mail'; } else { $report['error'] = $sbscrbr_options['cannot_send_email']; } } } return $report; }