Exemple #1
0
 function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
 {
     try {
         $sent = wpMandrill::mail($to, $subject, $message, $headers, $attachments);
         if (is_wp_error($sent) || !isset($sent[0]['status']) || $sent[0]['status'] != 'sent' && $sent[0]['status'] != 'queued') {
             return wpMandrill::wp_mail_native($to, $subject, $message, $headers, $attachments);
         }
         return true;
     } catch (Exception $e) {
         return wpMandrill::wp_mail_native($to, $subject, $message, $headers, $attachments);
     }
 }
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
// Additional headers
// @1.3.2 - fix issue with double to address in mail headers
//$headers .= 'To: '.$to. '' . "\r\n";
$headers .= 'From: ' . $from . '' . "\r\n";
if ($copy_address != '') {
    $headers .= 'Bcc: ' . $copy_address . "\r\n";
}
// Mail it
//$headers .= "Return-Path: <" . mysql_real_escape_string(trim($from)) . ">\n";
$message_body = str_replace("\r\n", "<br />", $message_body);
$json = array("message" => "");
if ($from != '' && $to != '' && $valid_captcha) {
    //@wp_mail($to, $message_subject, $message_body, $headers);
    if ($use_wpmandrill == "true") {
        wpMandrill::mail($to, $message_subject, $message_body, $headers);
    } else {
        if ($mail_function_command == "wp") {
            wp_mail($to, $message_subject, $message_body, $headers);
        } else {
            mail($to, $message_subject, $message_body, $headers);
        }
    }
    $json['message'] = "Message sent!";
    if ($translate_mail_message_sent != '') {
        $json['message'] = $translate_mail_message_sent;
    }
} else {
    $json['message'] = "Error sending message!";
    if ($translate_mail_message_error_send != '') {
        $json['message'] = $translate_mail_message_error_send;
function saos_user_build()
{
    $data = $_POST;
    $html_start = '
    
    <html>
    <body>
    
    ';
    $html_end = '
    
    </body>
    </head>
    
    ';
    $body = $html_start . stripcslashes($data['content']) . $html_end;
    $user_body = $html_start . stripcslashes($data['user_content']) . $html_end;
    wpMandrill::mail($data['user_email'], $data['user_subject'], $user_body, $headers = '', $attachments = array(), $tags = array(), $from_name = $data['from_name'], $from_email = $data['from_email'], $template_name = '');
}
 /**
  * Send email using WP's mailer. If WooCommerce is installed, WooCommerce's mailer
  * will be used unless WPMandrill is installed and configured
  * @param $to
  * @param $subject
  * @param $message
  * @param string|array $headers
  * @param string $attachments
  */
 public static function mail($to, $subject, $message, $headers = '', $attachments = '')
 {
     // inject CSS rules for text and image alignment
     $css = self::get_html_email_css();
     $message = $css . $message;
     // Send through Mandrill if WP Mandrill is installed
     if (class_exists('wpMandrill')) {
         $site_url_parts = parse_url(get_bloginfo('url'));
         $ga_campaign = defined('FUE_GA_CAMPAIGN') ? FUE_GA_CAMPAIGN : '';
         $ga_domain = $ga_campaign ? array($site_url_parts['host']) : array();
         $settings = get_option('wpmandrill', array());
         if (!empty($ga_campaign)) {
             $ga_campaign = json_decode($ga_campaign);
         }
         wpMandrill::mail($to, $subject, $message, $headers, $attachments, array(), $settings['from_name'], $settings['from_username'], '', true, true, false, true, array(), array(), $ga_domain, $ga_campaign);
     } else {
         // allow add-ons to use their own mailers
         $method = apply_filters('fue_mail_method', 'wp_mail');
         // if 'wp_mail' is still the mailer, see if Mandrill is available
         if ($method == 'wp_mail') {
             add_filter('wp_mail_content_type', 'FUE_Sending_Mailer::set_html_content_type');
             wp_mail($to, $subject, $message, $headers, $attachments);
             remove_filter('wp_mail_content_type', 'FUE_Sending_Mailer::set_html_content_type');
         } else {
             call_user_func($method, $to, $subject, $message, $headers, $attachments);
         }
     }
 }