Exemplo n.º 1
0
$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;
Exemplo n.º 2
0
 function http_request($url, $fields = array(), $method = 'POST')
 {
     if (!in_array($method, array('POST', 'GET'))) {
         $method = 'POST';
     }
     if (!isset($fields['key'])) {
         $fields['key'] = $this->api;
     }
     //some distribs change arg sep to &amp; by default
     $sep_changed = false;
     if (ini_get("arg_separator.output") != "&") {
         $sep_changed = true;
         $orig_sep = ini_get("arg_separator.output");
         ini_set("arg_separator.output", "&");
     }
     $fields = is_array($fields) ? http_build_query($fields) : $fields;
     if ($sep_changed) {
         ini_set("arg_separator.output", $orig_sep);
     }
     $useragent = wpMandrill::getUserAgent();
     if (function_exists('curl_init') && function_exists('curl_exec')) {
         if (!ini_get('safe_mode')) {
             set_time_limit(2 * 60);
         }
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_POST, $method == 'POST');
         curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         // @Bruno Braga:
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         //	Thanks for the hack!
         curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2 * 60 * 1000);
         $response = curl_exec($ch);
         $info = curl_getinfo($ch);
         $error = curl_error($ch);
         curl_close($ch);
     } elseif (function_exists('fsockopen')) {
         $parsed_url = parse_url($url);
         $host = $parsed_url['host'];
         if (isset($parsed_url['path'])) {
             $path = $parsed_url['path'];
         } else {
             $path = '/';
         }
         $params = '';
         if (isset($parsed_url['query'])) {
             $params = $parsed_url['query'] . '&' . $fields;
         } elseif (trim($fields) != '') {
             $params = $fields;
         }
         if (isset($parsed_url['port'])) {
             $port = $parsed_url['port'];
         } else {
             $port = $parsed_url['scheme'] == 'https' ? 443 : 80;
         }
         $response = false;
         $errno = '';
         $errstr = '';
         ob_start();
         $fp = fsockopen('ssl://' . $host, $port, $errno, $errstr, 5);
         if ($fp !== false) {
             stream_set_timeout($fp, 30);
             $payload = "{$method} {$path} HTTP/1.0\r\n" . "Host: {$host}\r\n" . "Connection: close\r\n" . "User-Agent: {$useragent}\r\n" . "Content-type: application/x-www-form-urlencoded\r\n" . "Content-length: " . strlen($params) . "\r\n" . "Connection: close\r\n\r\n" . $params;
             fwrite($fp, $payload);
             stream_set_timeout($fp, 30);
             $info = stream_get_meta_data($fp);
             while (!feof($fp) && !$info["timed_out"]) {
                 $response .= fread($fp, 4096);
                 $info = stream_get_meta_data($fp);
             }
             fclose($fp);
             ob_end_clean();
             list($headers, $response) = explode("\r\n\r\n", $response, 2);
             if (ini_get("magic_quotes_runtime")) {
                 $response = stripslashes($response);
             }
             $info = array('http_code' => 200);
         } else {
             ob_end_clean();
             $info = array('http_code' => 500);
             throw new Exception($errstr, $errno);
         }
         $error = '';
     } else {
         throw new Mandrill_Exception("No valid HTTP transport found", -99);
     }
     return array('header' => $info, 'body' => $response, 'error' => $error);
 }
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 = '');
}
Exemplo n.º 4
0
	                        } ],
	               legend: { position: 'ne', margin: [20, 10]}
		});
});
</script>
<h3><?php 
echo $lit['hourly']['title'];
?>
</h3>
<h4><?php 
echo $lit['subtitle'];
?>
</h4>
    <div id="hourly_report_canvas" style="height: 400px;"></div><br/><br/>
<h3><?php 
echo $lit['daily']['title'];
?>
</h3>
<h4><?php 
echo $lit['subtitle'];
?>
</h4>
    <div id="daily_report_canvas" style="height: 400px;"></div>
    <h3><a href="http://mandrillapp.com/" target="_target"><?php 
_e('For more detailed statistics, please visit your Mandrill Dashboard', 'wpmandrill');
?>
</a>.</h3>

		<?php 
wpMandrill::$stats = $stats;
Exemplo n.º 5
0
 static function getConnected()
 {
     if (!isset(self::$mandrill)) {
         try {
             require_once plugin_dir_path(__FILE__) . '/lib/mandrill.class.php';
             self::$mandrill = new Mandrill(self::getAPIKey());
         } catch (Exception $e) {
         }
     }
 }
Exemplo n.º 6
0
 /**
  * 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);
         }
     }
 }
/**
 * Get the notification strategy.
 *
 * @internal
 *
 * @since 1.0
 *
 * @return \IronBound\WP_Notifications\Strategy\Strategy
 */
function get_notification_strategy()
{
    if (class_exists('wpMandrill') && ($c = \wpMandrill::getConnected() && \wpMandrill::isConnected())) {
        $key = \wpMandrill::getAPIKey();
        $strategy = new Mandrill_Strategy(new Mandrill_API($key));
    } elseif (defined('ITELIC_Mandrill') && class_exists('Mandrill')) {
        $key = ITELIC_Mandrill;
        $strategy = new Mandrill_Strategy(new Mandrill_API($key));
    } else {
        $strategy = new iThemes_Exchange();
    }
    /**
     * Get a notifications strategy.
     *
     * @since 1.0
     *
     * @param \IronBound\WP_Notifications\Strategy\Strategy $strategy
     * @param string                                        $batch_name
     */
    return apply_filters('itelic_get_queue_processor', $strategy);
}
    private function send_email($template_name, $subject, $to, $recipient_name, $content=array(), $pdf=null)
    {
        //FOR TESTING
        $amachome = 'http://hicalibertest.com.au/amac/'; //home_url();
        $amaclogo = $amachome.'/wp-content/themes/amac/assets/images/logo.png'; //home_url('/wp-content/themes/amac/assets/images/logo.png');

        $message = array(
            'subject' => $subject,
            'to' => array(
                array(
                    'email' => $to,
                    'name' => $recipient_name,
                    'type' => 'to'
                )
            ),
            'html' => array(
                array( 'name'=>'amachome', 'content'=> "<a href='$amachome'>www.amac.org.au</a>" ),
                array( 'name'=>'amaclogo', 'content'=> "<img style='width:100%;' src='$amaclogo'></img>" ),
            )
        );

        foreach ($content as $key => $value) 
        {
            $message['html'][] = array('name'=>$key, 'content'=>$value);
        }

        if(!empty($pdf))
        {
            $message['attachments'] =  DocHandler::pdf_upload_dir($pdf);
        }
        
        wpMandrill::sendEmail($message, null ,$template_name);
    }