public function send_a_contact() { $profile_email = trim($_REQUEST['profile_email']); $profile_name = trim($_REQUEST['profile_name']); $c_name = trim($_REQUEST['c_name']); $c_email = trim($_REQUEST['c_email']); $c_phone = trim($_REQUEST['c_phone']); $c_message = trim($_REQUEST['c_message']); $send_copy = $_REQUEST['send_copy']; if (trim($_REQUEST['c_subject']) != '') { $subject = trim($_REQUEST['c_subject']) . ' ' . people_ict_t__('Email Inquiry - from', __('from', 'cup_cp')) . ' ' . (function_exists('icl_t') ? icl_t('WP', __('Blog Title', 'wpml-string-translation'), get_option('blogname')) : get_option('blogname')); } else { $subject = people_ict_t__('Email Inquiry - Contact from', __('Contact from', 'cup_cp')) . ' ' . (function_exists('icl_t') ? icl_t('WP', __('Blog Title', 'wpml-string-translation'), get_option('blogname')) : get_option('blogname')); } $profile_data = array('subject' => $subject, 'to_email' => $profile_email, 'profile_name' => $profile_name, 'profile_email' => $profile_email, 'contact_name' => $c_name, 'contact_email' => $c_email, 'contact_phone' => $c_phone, 'message' => $c_message); $email_result = People_Contact_Functions::contact_to_people($profile_data, $send_copy); echo $email_result; die; }
public static function contact_to_site($contact_data = array(), $send_copy_yourself = 1) { global $people_contact_widget_email_contact_form; $contact_success = people_ict_t__('Contact Widget - Success Message', __("Thanks for your contact - we'll be in touch with you as soon as possible!", 'cup_cp')); if ($people_contact_widget_email_contact_form['widget_email_to'] == '') { $to_email = get_option('admin_email'); } else { $to_email = $people_contact_widget_email_contact_form['widget_email_to']; } $cc_emails = ''; if (trim($people_contact_widget_email_contact_form['widget_email_cc']) != '') { $cc_emails = $people_contact_widget_email_contact_form['widget_email_cc']; } if ($people_contact_widget_email_contact_form['widget_email_from_name'] == '') { $from_name = get_option('blogname'); } else { $from_name = $people_contact_widget_email_contact_form['widget_email_from_name']; } if ($people_contact_widget_email_contact_form['widget_email_from_address'] == '') { $from_email = get_option('admin_email'); } else { $from_email = $people_contact_widget_email_contact_form['widget_email_from_address']; } $headers = array(); $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=' . get_option('blog_charset'); $headers[] = 'From: ' . $from_name . ' <' . $from_email . '>'; $headers_yourself = $headers; if (trim($cc_emails) != '') { $cc_emails_a = explode(",", $cc_emails); if (is_array($cc_emails_a) && count($cc_emails_a) > 0) { foreach ($cc_emails_a as $cc_email) { $headers[] = 'Cc: ' . $cc_email; } } else { $headers[] = 'Cc: ' . $cc_emails; } } $subject_yourself = people_ict_t__('Contact Widget - Copy', __('[Copy]:', 'cup_cp')) . ' ' . stripslashes($contact_data['subject']); $content = ' <table width="99%" cellspacing="0" cellpadding="1" border="0" bgcolor="#eaeaea"><tbody> <tr> <td> <table width="100%" cellspacing="0" cellpadding="5" border="0" bgcolor="#ffffff"><tbody> <tr bgcolor="#eaf2fa"> <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . people_ict_t__('Contact Widget - Name', __('Name', 'cup_cp')) . '</strong></font> </td></tr> <tr bgcolor="#ffffff"> <td width="20"> </td> <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px">[contact_name]</font> </td></tr> <tr bgcolor="#eaf2fa"> <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . people_ict_t__('Contact Widget - Email Address', __('Email Address', 'cup_cp')) . '</strong></font> </td></tr> <tr bgcolor="#ffffff"> <td width="20"> </td> <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><a target="_blank" href="mailto:[contact_email]">[contact_email]</a></font> </td></tr> <tr bgcolor="#eaf2fa"> <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . people_ict_t__('Contact Widget - Message', __('Message', 'cup_cp')) . '</strong></font> </td></tr> <tr bgcolor="#ffffff"> <td width="20"> </td> <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px">[message]</font> </td></tr></tbody></table></td></tr></tbody></table>'; $content = str_replace('[contact_name]', esc_attr(stripslashes($contact_data['contact_name'])), $content); $content = str_replace('[contact_email]', esc_attr(stripslashes($contact_data['contact_email'])), $content); $your_message = esc_attr(stripslashes(strip_tags($contact_data['message']))); $your_message = str_replace('://', ':­//', $your_message); $your_message = str_replace('.com', '­.com', $your_message); $your_message = str_replace('.net', '­.net', $your_message); $your_message = str_replace('.info', '­.info', $your_message); $your_message = str_replace('.org', '­.org', $your_message); $your_message = str_replace('.au', '­.au', $your_message); $content = str_replace('[message]', wpautop($your_message), $content); $content = apply_filters('people_contact_contact_site_content', $content, $contact_data); // Filters for the email add_filter('wp_mail_from', array('People_Contact_Functions', 'get_from_address')); add_filter('wp_mail_from_name', array('People_Contact_Functions', 'get_from_name')); add_filter('wp_mail_content_type', array('People_Contact_Functions', 'get_content_type')); wp_mail($to_email, stripslashes($contact_data['subject']), $content, $headers, ''); if ($send_copy_yourself == 1) { wp_mail(esc_attr(stripslashes($contact_data['contact_email'])), $subject_yourself, $content, $headers_yourself, ''); } // Unhook filters remove_filter('wp_mail_from', array('People_Contact_Functions', 'get_from_address')); remove_filter('wp_mail_from_name', array('People_Contact_Functions', 'get_from_name')); remove_filter('wp_mail_content_type', array('People_Contact_Functions', 'get_content_type')); return $contact_success; }