function send_mail($mailtos, $body, $target)
{
    global $language;
    // $subject = ( $language->language == 'nl' )
    //     ? 'Welkom bij Comfort Energy '
    //     : 'Bienvenue à Comfort Energy';
    $subject = tt('cr_subjectline_confirmation_mail');
    # add something to the subject that makes it unique (within 10 seconds) and goes up
    if ($target == 'dev_victim') {
        $subject .= ' (' . floor((time() - 1427268600) / 10) . ')';
    }
    # not live and not staging? => don't allow mails being sent to comfort energy
    $tbwa_config = tbwa_config_php();
    if ($tbwa_config['environment'] !== 'live' && $tbwa_config['environment'] !== 'staging') {
        if ($target == 'comfort_energy') {
            return array('debug' => '=> comfort energy: not sending');
        }
    }
    # structure it the Mandrill way
    $mailtos = array_map(function ($e) {
        return array('email' => $e, 'type' => 'to');
    }, $mailtos);
    # message parameters
    $message = array("key" => 'MN7hyMoFVC0Zo4ZwYM83hw', "message" => array('to' => $mailtos, "from_name" => 'Comfort Energy', 'from_email' => '*****@*****.**', 'subject' => $subject, 'html' => $body, 'text' => 'Please view this mail with a mail client that supports HTML.', 'track_opens' => true, 'subaccount' => '11COE15001_Comfort_Energy'));
    //     echo '<pre>';
    //     print_r($message['message']['html']);
    //     exit;
    $message = array('subject' => 'Test message', 'from_email' => 'MyEmailAddress', 'html' => '<p>this is a test message with Mandrill\'s PHP wrapper!.</p>', 'to' => array(array('email' => 'MyEmailAddress', 'name' => 'David Splat')), 'merge_vars' => array(array('rcpt' => 'MyEmailAddress', 'vars' => array(array('name' => 'FIRSTNAME', 'content' => $fName), array('name' => 'LASTNAME', 'content' => $lName)))));
    # send message
    $mandrill = new \Mandrill('MN7hyMoFVC0Zo4ZwYM83hw');
    $result = $mandrill->call('/messages/send', $message);
    return $result;
}
Ejemplo n.º 2
0
<?php

/**
 * This examples shows how Mandrill library is used to obtain information about a user.
 */
require '../Mandrill.php';
require 'config.php';
Mandrill::call(array('type' => 'users', 'call' => 'ping'));
Ejemplo n.º 3
0
<?php

/**
 * This examples shows how Mandrill library is used to obtain information about a user.
 */
require '../Mandrill.php';
require 'config.php';
Mandrill::call(array('type' => 'webhooks', 'call' => 'list'));
Ejemplo n.º 4
0
    $email['call'] = 'send';
    $message = array();
    $message['html'] = $html_email;
    $message['text'] = $text_email;
    $message['subject'] = 'Trial Registration - workforce.fm';
    $message['from_email'] = '*****@*****.**';
    $message['from_name'] = 'Workforce Trial Registration';
    //$message['to'][] = array('email'=>'*****@*****.**', 'name'=>'Mo Raza');
    $message['to'][] = array('email' => '*****@*****.**', 'name' => 'Damien Knight');
    //$message['to'][] = array('email'=>'*****@*****.**', 'name'=>'VERB');
    $message['track_opens'] = true;
    $message['track_clicks'] = true;
    $message['auto_text'] = true;
    $message['url_strip_qs'] = true;
    $email['message'] = $message;
    $ret = Mandrill::call_api($email);
    $response = json_decode($json_response, true);
    $result['success'] = true;
    $result['data'] = $response;
    $result['response_message'] = 'Thanks for signing up, A member of the team will be in touch shortly to progress your account.';
    header("Content-Type: application/json");
    echo json_encode($result);
} else {
    $result['exists'] = false;
    $result['response'] = false;
    header("Content-Type: application/json");
    echo json_encode($result);
}
die;
//WSDL FILE
$wsdl = "https://login.workforce.fm/wpfront.asmx?WSDL";
Ejemplo n.º 5
0
 /**
  * @covers ::__construct
  * @covers ::configDefaults
  * @covers ::getMandrill
  * @group  Email
  */
 public function testConstruct()
 {
     $mock = \Mockery::mock('Mandrill');
     $object = new Mandrill($mock, $this->getConfig());
     $this->assertSame($mock, $object->getMandrill());
 }
 public function sendMessage()
 {
     $apiKey = $this->_helper->getApiKey();
     $api = new \Mandrill($apiKey);
     $message = array('subject' => $this->_message->getSubject(), 'from_name' => $this->_message->getFromName(), 'from_email' => $this->_message->getFrom());
     foreach ($this->_message->getTo() as $to) {
         $message['to'][] = array('email' => $to);
     }
     foreach ($this->_message->getBbc() as $bcc) {
         $message['to'][] = array('email' => $bcc, 'type' => 'bcc');
     }
     if ($att = $this->_message->getAttachments()) {
         $message['attachments'] = $att;
     }
     if ($headers = $this->_message->getHeaders()) {
         $message['headers'] = $headers;
     }
     switch ($this->_message->getType()) {
         case \Magento\Framework\Mail\MessageInterface::TYPE_HTML:
             $message['html'] = $this->_message->getBody();
             break;
         case \Magento\Framework\Mail\MessageInterface::TYPE_TEXT:
             $message['text'] = $this->_message->getBody();
             break;
     }
     $api->call('messages/send', array("message" => $message));
     return;
 }
Ejemplo n.º 7
-1
 public static function handleRedirectReturn($data = false)
 {
     if (!isset($data['key'])) {
         return 'There was an error. (general) Please try again.';
     } else {
         require_once CASH_PLATFORM_ROOT . '/lib/mandrill/Mandrill.php';
         $m = new Mandrill($data['key']);
         $user_info = $m->getUserInfo();
         $username = $user_info['username'];
         // we can safely assume (AdminHelper::getPersistentData('cash_effective_user') as the OAuth
         // calls would only happen in the admin. If this changes we can f**k around with it later.
         $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user'));
         $result = $new_connection->setSettings($username . ' (Mandrill)', 'com.mandrillapp', array('key' => $data['key']));
         if (!$result) {
             return 'There was an error. (adding the connection) Please try again.';
         }
         // set up webhooks
         $api_credentials = CASHSystem::getAPICredentials();
         $webhook_api_url = CASH_API_URL . '/verbose/people/processwebhook/origin/com.mandrillapp/api_key/' . $api_credentials['api_key'];
         //$m->webhooksDelete($webhook_api_url); // remove duplicate webhooks
         //$m->webhooksAdd($webhook_api_url,array('send','hard_bounce','soft_bounce','open','click','spam','unsub','reject')); // add it, all events
         $m->call('webhooks/add', array("url" => $webhook_api_url, "events" => array('hard_bounce', 'soft_bounce', 'open', 'click', 'spam', 'unsub', 'reject')));
         if (isset($data['return_result_directly'])) {
             return $result;
         } else {
             if ($result) {
                 AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/');
             } else {
                 AdminHelper::formFailure('Error. Something just didn\'t work right.');
             }
         }
     }
 }
Ejemplo n.º 8
-1
 /**
  * Save Settings
  */
 public function saveSettings()
 {
     /* Are we turning off? */
     if (ipsRegistry::$request['off']) {
         IPSLib::updateSettings(array('mandrill_username' => '', 'mandrill_api_key' => ''));
         ipsRegistry::getClass('output')->silentRedirect(ipsRegistry::$settings['_base_url'] . "app=core&amp;module=applications&amp;section=enhancements&amp;do=edit&amp;service=enhancements_members_mandrill");
         return;
     }
     /* Load language files so we have error messages if we need em */
     ipsRegistry::getClass('class_localization')->loadLanguageFile('admin_bulkmail', 'members');
     /* Are we adding new values or just enabling SMTP? */
     if (ipsRegistry::$request['smtp_on']) {
         ipsRegistry::$request['username'] = ipsRegistry::$settings['mandrill_username'];
         ipsRegistry::$request['api_key'] = ipsRegistry::$settings['mandrill_api_key'];
         ipsRegistry::$request['smtp'] = 1;
         $update = array();
     } else {
         /* Trim (like a haircut, but with strings) */
         ipsRegistry::$request['username'] = trim(ipsRegistry::$request['username']);
         ipsRegistry::$request['api_key'] = trim(ipsRegistry::$request['api_key']);
         /* If we don't have anything, tell them off */
         if (!ipsRegistry::$request['username'] or !ipsRegistry::$request['username']) {
             return $this->editSettings('mandrill_setup_noinfo');
         }
         /* Now shoot that over to Mandrill to make sure they're cool with it */
         require_once IPSLib::getAppDir('members') . '/sources/classes/mandrill.php';
         $mandrill = new Mandrill(ipsRegistry::$request['api_key']);
         $info = $mandrill->users_info();
         if ($info === NULL or $info->username != ipsRegistry::$request['username']) {
             return $this->editSettings('mandrill_bad_credentials');
         }
         /* So we're saving at least the API key and the username */
         $update = array('mandrill_username' => ipsRegistry::$request['username'], 'mandrill_api_key' => ipsRegistry::$request['api_key']);
     }
     /* Fire that off to IPS so Mandrill knows it's one of ours */
     $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement');
     $file = new $classToLoad();
     $json = NULL;
     /* If they want to use Mandrill for SMTP too, that call will contain the SMTP info,
        so set it if we got it, or if the call failed, throw an error */
     if (ipsRegistry::$request['smtp']) {
         if ($json) {
             $json = json_decode($json, TRUE);
             $update = array_merge($update, $json);
         } else {
             return $this->editSettings('mandrill_error');
         }
     }
     /* Update the settings */
     IPSLib::updateSettings($update);
     /* And boink the hell out of it */
     ipsRegistry::getClass('output')->silentRedirect(ipsRegistry::$settings['_base_url'] . "app=core&amp;module=applications&amp;section=enhancements&amp;do=edit&amp;service=enhancements_members_mandrill");
     return;
 }
Ejemplo n.º 9
-1
 public function sendmail($from, $to, $subject, $body, $altbody = null, $options = null, $attachments = null, $html = false)
 {
     if (!is_array($from)) {
         $from = array($from, $from);
     }
     if (!is_array($to)) {
         $to = array('email' => $to, 'name' => $to);
     }
     if (key_exists('reply-to', $options)) {
         $headers = array('Reply-To' => $options['reply-to']);
     }
     if (null != $attachments) {
         if (!is_array($attachments)) {
             $attachments = array($attachments);
         }
         foreach ($attachments as $k => $v) {
             $arr = array('type' => "application/octet-stream", 'name' => basename($v), 'content' => base64_encode(file_get_contents($v)));
             $attachments_request[] = $arr;
         }
     }
     if (!$html) {
         $altbody = $body;
         $body = null;
     }
     $message = array('html' => $body, 'text' => $altbody, 'subject' => $subject, 'from_email' => $from[0], 'from_name' => $from[1], 'to' => array($to), 'headers' => $headers, 'attachments' => $attachments_request);
     $request = array('type' => 'messages', 'call' => 'send', 'message' => $message);
     //    $ret = Mandrill::call($request);
     $ret = Mandrill::__callStatic('call', array($request));
 }
Ejemplo n.º 10
-1
 function send($msg = '', $data = array())
 {
     global $app;
     $mandrill = new Mandrill(config('mandrill.apikey'));
     if (!is_array($msg)) {
         parse_str($msg, $msg);
     }
     foreach (array('text', 'html') as $t) {
         if (!empty($msg[$t]) && strpos(trim($msg[$t]), 'slim:') === 0) {
             $view = new \Slim\View();
             $view->appendData($data);
             $view->setTemplatesDirectory($app->config('templates.path'));
             $msg[$t] = $view->fetch('email/' . substr(trim($msg[$t]), 5));
         }
     }
     if (isset($msg['from'])) {
         $msg['from_email'] = $msg['from'];
         unset($msg['from']);
     }
     if (!is_array($msg['to'])) {
         $msg['to'] = array(array('email' => $msg['to']));
     }
     return $mandrill->call('/messages/send', array('message' => $msg));
 }
Ejemplo n.º 11
-1
 /**
  * Overwrite to allow empty params.
  *
  * @param string $url
  * @param array $params
  * @return array Result
  */
 public function call($url, $params = [])
 {
     return parent::call($url, $params);
 }
Ejemplo n.º 12
-1
 static function getAttachmentStruct($path)
 {
     $struct = array();
     try {
         if (!@is_file($path)) {
             throw new Exception($path . ' is not a valid file.');
         }
         $filename = basename($path);
         if (!function_exists('get_magic_quotes')) {
             function get_magic_quotes()
             {
                 return false;
             }
         }
         if (!function_exists('set_magic_quotes')) {
             function set_magic_quotes($value)
             {
                 return true;
             }
         }
         if (strnatcmp(phpversion(), '6') >= 0) {
             $magic_quotes = get_magic_quotes_runtime();
             set_magic_quotes_runtime(0);
         }
         $file_buffer = file_get_contents($path);
         $file_buffer = chunk_split(base64_encode($file_buffer), 76, "\n");
         if (strnatcmp(phpversion(), '6') >= 0) {
             set_magic_quotes_runtime($magic_quotes);
         }
         if (strnatcmp(phpversion(), '5.3') >= 0) {
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
             $mime_type = finfo_file($finfo, $path);
         } else {
             $mime_type = mime_content_type($path);
         }
         if (!Mandrill::isValidContentType($mime_type)) {
             throw new Exception($mime_type . ' is not a valid content type (it should be ' . implode('*,', self::getValidContentTypes()) . ').');
         }
         $struct['type'] = $mime_type;
         $struct['name'] = $filename;
         $struct['content'] = $file_buffer;
     } catch (Exception $e) {
         throw new Mandrill_Exception('Error creating the attachment structure: ' . $e->getMessage());
     }
     return $struct;
 }
Ejemplo n.º 13
-1
<?php

/**
 * This examples shows how Mandrill library is used to send a message.
 */
require '../Mandrill.php';
require 'config.php';
$request_json = '{"type":"messages","call":"send","message":{"html": "<h1>test</h1>", "text": "example text", "subject": "Google", "from_email": "*****@*****.**", "from_name": "Esferasoft", "to":[{"email": "*****@*****.**", "name": "Wes Widner"}],"headers":{"...": "..."},"track_opens":true,"track_clicks":true,"auto_text":true,"url_strip_qs":true,"tags":["test","example","sample"],"google_analytics_domains":["werxltd.com"],"google_analytics_campaign":["..."],"metadata":["..."]}}';
$ret = Mandrill::call((array) json_decode($request_json));
print_r($ret);
Ejemplo n.º 14
-1
<?php

/**
 * This examples shows how Mandrill library is used to obtain information about a user.
 */
require '../Mandrill.php';
require 'config.php';
Mandrill::call(array('type' => 'users', 'call' => 'info'));
	public function mandrill_send_email( $to, $subject, $message, $headers = '', $attachments = array(),
							$tags = array(), 
	                        $from_name = '', 
	                        $from_email = '', 
	                        $template_name = '', 
	                        $track_opens = null, 
	                        $track_clicks = null,
	                        $url_strip_qs = false,
	                        $merge = true,
	                        $global_merge_vars = array(),
	                        $merge_vars = array(),
	                        $google_analytics_domains = array(),
	                        $google_analytics_campaign = array(),
	                        $meta_data = array(),
	                        $important = false,
	                        $inline_css = null,
	                        $preserve_recipients=null,
	                        $view_content_link=null,
	                        $tracking_domain=null,
	                        $signing_domain=null,
	                        $return_path_domain=null,
	                        $subaccount=null,
	                        $recipient_metadata=null,
	                        $ip_pool=null,
	                        $send_at=null,
	                        $async=null 
						) {
		global $wp_et_mandrill_provider_configuration;
		
		$to = str_replace( '<', '', $to );
		$to = str_replace( '>', '', $to );
		$bcc_list = array();
		$cc_list = array();
		
		try {
			require_once WP_EMAIL_TEMPLATE_DIR. '/includes/mandrill/Mandrill.php';
			$mandrill = new Mandrill( $wp_et_mandrill_provider_configuration['api_key'] );
						
			extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
			$html = $message;
			$mandrill_message = compact('html', 'subject', 'from_name', 'from_email', 'to', 'headers', 'attachments', 
                                    'url_strip_qs', 
                                    'merge', 
                                    'global_merge_vars', 
                                    'merge_vars',
                                    'google_analytics_domains',
                                    'google_analytics_campaign',
                                    'meta_data',
            						'important',
        							'inline_css',
        							'preserve_recipients',
        							'view_content_link',
        							'tracking_domain',
        							'signing_domain',
        							'return_path_domain',
        							'subaccount',
        							'recipient_metadata',
        							'ip_pool',
        							'send_at',
        							'async'        	
                                    );
			
			if ( empty( $mandrill_message['headers'] ) ) {
				$mandrill_message['headers'] = array();
			} else {
				if ( !is_array( $mandrill_message['headers'] ) ) {
					$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $mandrill_message['headers'] ) );
				} else {
					$tempheaders = $mandrill_message['headers'];
				}
				$mandrill_message['headers'] = array();

				// If it's actually got contents
				if ( !empty( $tempheaders ) ) {
					// Iterate through the raw headers
					foreach ( (array) $tempheaders as $header ) {
						if ( strpos($header, ':') === false ) continue;

						// Explode them out
						list( $name, $content ) = explode( ':', trim( $header ), 2 );

						// Cleanup crew
						$name    = trim( $name    );
						$content = trim( $content );

						switch ( strtolower( $name ) ) {
							case 'from':
								if ( strpos($content, '<' ) !== false ) {
									// So... making my life hard again?
									$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
									$from_name = str_replace( '"', '', $from_name );
									$from_name = trim( $from_name );

									$from_email = substr( $content, strpos( $content, '<' ) + 1 );
									$from_email = str_replace( '>', '', $from_email );
									$from_email = trim( $from_email );
								} else {
									$from_name  = '';
									$from_email = trim( $content );
								}
								$mandrill_message['from_email']  = $from_email;
								$mandrill_message['from_name']   = $from_name;						            
								break;
						            
							case 'bcc':
								// TODO: Mandrill's API only accept one BCC address. Other addresses will be silently discarded
								$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
					            
								$bcc_list = $bcc;    
								break;
							
							case 'cc':
								$cc = array_merge( (array) $cc, explode( ',', $content ) );
					            
								$cc_list = $cc;    
								break;
						            
							case 'reply-to':
						            $mandrill_message['headers'][trim( $name )] = trim( $content );
								break;
							case 'importance':
							case 'x-priority':
							case 'x-msmail-priority':
								if ( !$mandrill_message['important'] ) $mandrill_message['important'] = ( strpos(strtolower($content),'high') !== false ) ? true : false;
								break;
							default:
								if ( substr($name,0,2) == 'x-' ) {
    						            $mandrill_message['headers'][trim( $name )] = trim( $content );
								}
								break;
						}
					}
				}
			}
			
			 // Adding a Reply-To header
			if ( !in_array( 'reply-to', array_map( 'strtolower', array_keys($mandrill_message['headers']) ) ) ) {
				$mandrill_message['headers']['Reply-To'] = get_option('admin_email');
			}

	        // Checking To: field
			if( !is_array($mandrill_message['to']) ) $mandrill_message['to'] = explode(',', $mandrill_message['to']);
                
			$processed_to = array();
			foreach ( $mandrill_message['to'] as $email ) {
				if ( is_array($email) ) {
                	$processed_to[] = $email;
				} else { 
                	$processed_to[] = array( 'email' => $email );
				}
			}
			
			if ( is_array( $bcc_list ) && count( $bcc_list ) > 0 ) {
				foreach ( $bcc_list as $bcc_email ) {
					$bcc_email = str_replace( '<', '', $bcc_email );
					$bcc_email = str_replace( '>', '', $bcc_email );
					$processed_to[] = array( 'email' => $bcc_email, 'type' => 'bcc' );
				}
			}
			
			if ( is_array( $cc_list ) && count( $cc_list ) > 0 ) {
				foreach ( $cc_list as $cc_email ) {
					$cc_email = str_replace( '<', '', $cc_email );
					$cc_email = str_replace( '>', '', $cc_email );
					$processed_to[] = array( 'email' => $cc_email, 'type' => 'cc' );
				}
			}
			
			$mandrill_message['to'] = $processed_to;
	        
	        // Checking From: field
			if ( empty($mandrill_message['from_email']) ) $mandrill_message['from_email'] = get_option('admin_email');
			if ( empty($mandrill_message['from_name'] ) ) $mandrill_message['from_name']  = get_option('blogname');
            
            // Checking tags.
			$mandrill_message['tags']        = $mandrill->findTags($tags);
		    
		    // Checking attachments
			if ( !empty($mandrill_message['attachments']) ) {
				$mandrill_message['attachments'] = $mandrill->processAttachments($mandrill_message['attachments']);
				if ( is_wp_error($mandrill_message['attachments']) ) {
					$this->set_mandrill_send_email_error( 'Invalid attachment.' );
				} elseif ( !is_array($mandrill_message['attachments']) ) {	// some plugins return this value malformed.
					unset($mandrill_message['attachments']);
				}
			}
		    // Default values for other parameters
			$mandrill_message['auto_text']   = true;
			$mandrill_message['track_opens'] = $wp_et_mandrill_provider_configuration['enable_track_opens'];
			$mandrill_message['track_clicks']= $wp_et_mandrill_provider_configuration['enable_track_clicks'];
                
            // Letting user to filter/change the mandrill_message payload
			$mandrill_message['from_email']  = apply_filters('wp_mail_from', $mandrill_message['from_email']);
			$mandrill_message['from_name']	= apply_filters('wp_mail_from_name', $mandrill_message['from_name']);
                
			// if user doesn't want to process this email by wp_mandrill, so be it.
			if ( isset($mandrill_message['force_native']) && $mandrill_message['force_native'] ) $this->set_mandrill_send_email_error( 'Manually falling back to native wp_mail()' );
                
            // Setting the tags property correctly to be received by the Mandrill's API
			if ( !is_array($mandrill_message['tags']['user']) )      $mandrill_message['tags']['user']        = array();
			if ( !is_array($mandrill_message['tags']['general']) )   $mandrill_message['tags']['general']     = array();
			if ( !is_array($mandrill_message['tags']['automatic']) ) $mandrill_message['tags']['automatic']   = array();
                
			$mandrill_message['tags'] = array_merge( $mandrill_message['tags']['general'], $mandrill_message['tags']['automatic'], $mandrill_message['tags']['user'] );
			
			$result = $mandrill->messages->send( $mandrill_message );
			
			if ( is_array( $result ) && $result[0]['status'] == 'sent' )
				return true;		
			else
				return false;
		} catch ( Exception $e ) {
			$this->set_mandrill_send_email_error( $e->getMessage() );
			return false;
		}
	}
Ejemplo n.º 16
-1
 public function __construct()
 {
     $this->apiKey = \Yii::$app->params['mail']['apiKey'];
     parent::__construct($this->apiKey);
 }
Ejemplo n.º 17
-1
function send_email($from, $fromname, $emailtos, $subject, $message, $template)
{
    $formvars['key'] = 'ed3f246e-b16c-4ffb-8a19-e0c36c8877ea';
    $formvars['template_name'] = $template['slug'];
    $formvars['template_content'] = array();
    foreach ($template['data'] as $key => $value) {
        $content = array();
        $content['name'] = $key;
        $content['content'] = $value;
        $formvars['template_content'][] = $content;
    }
    $formvars['message'] = array();
    //$formvars['message']['html'] = "test email";
    //$formvars['message']['text'] = "test email";
    $formvars['message']['subject'] = $subject;
    $formvars['message']['from_email'] = $from;
    $formvars['message']['from_name'] = $fromname;
    /*
    $email = array();
    $email['email'] = $to;
    $email['name'] = $toname;
    $formvars['message']['to'][] = $emails;
    */
    $formvars['message']['to'] = $emailtos;
    /*
    $formvars['message']['headers'] = array();
    $formvars['message']['headers']["X-MC-MergeVars"] = $template['data'];
    $formvars['message']['headers']["X-MC-Template"] = $template['slug'];
    */
    $formvars['message']['track_opens'] = true;
    $formvars['message']['track_clicks'] = true;
    $formvars['message']['auto_text'] = true;
    $formvars['message']['async'] = true;
    //exit();
    /*
    $sp = new Snoopy();
    //agent spoof and curl binary setup
    $sp->agent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)";
    if(isset($_SERVER['WINDIR']) && strpos($_SERVER['WINDIR'], 'Windows') !== false)
    	$sp->curl_path = dirname(__FILE__)."/magpie_0.72/extlib/curlwin32/curl";
    else
    	$sp->curl_path = "/usr/bin/curl"; //assumed return curl binary path for linux
    $sp->temp_dir = dirname(__FILE__)."/tmp";
    //$URI = "https://mandrillapp.com/api/1.0/messages/send.json";
    $URI = "http://mandrillapp.com/api/1.0/users/info.json";
    $sp->submit($URI, $formvars);
    echo $sp->results;
    */
    $m = new Mandrill('ed3f246e-b16c-4ffb-8a19-e0c36c8877ea');
    //print_r($m->call("users/info", $formvars['message']));
    $r = $m->call("messages/send-template", $formvars);
    if (trim($r[0]['status']) != 'sent') {
        print_r($formvars);
        print_r($r);
    }
}
Ejemplo n.º 18
-1
<?php

/**
 * This examples shows how Mandrill library is used to obtain information about a user.
 */
require '../Mandrill.php';
require 'config.php';
Mandrill::call(array('type' => 'users', 'call' => 'verify-sender', 'email' => '*****@*****.**'));
Ejemplo n.º 19
-1
 public function __construct()
 {
     $this->apiKey = "iWXEJKCA9DGqgNXxP__oJA";
     parent::__construct($this->apiKey);
 }
Ejemplo n.º 20
-1
<?php

/**
 * This examples shows how Mandrill library is used to obtain information about a user.
 */
require '../Mandrill.php';
require 'config.php';
Mandrill::call(array('type' => 'tags', 'call' => 'list'));
Ejemplo n.º 21
-1
 static function processAttachments($attachments = array())
 {
     if (!is_array($attachments) && $attachments) {
         $attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
     }
     foreach ($attachments as $index => $attachment) {
         try {
             $attachments[$index] = Mandrill::getAttachmentStruct($attachment);
         } catch (Exception $e) {
             error_log("\nwpMandrill::processAttachments: {$attachment} => " . $e->getMessage() . "\n");
             return new WP_Error($e->getMessage());
         }
     }
     return $attachments;
 }
Ejemplo n.º 22
-1
 public function testUserSenders()
 {
     $o = Mandrill::call(array('type' => 'users', 'call' => 'senders'));
     $this->assertTrue(is_array($o));
 }
Ejemplo n.º 23
-1
<?php

/**
 * This examples shows how Mandrill library is used to obtain information about a user.
 */
require '../Mandrill.php';
require 'config.php';
Mandrill::call(array('type' => 'users', 'call' => 'senders'));
Ejemplo n.º 24
-1
 /**
  * Rather than defining each method individually we use this method to route the
  * method call to the appropriate handler. This method should not be used directly.
  *
  * @param string $method Method user attempted to use
  * @param mixed $args Array of arguments the user passed to the method
  * @since 1.0
  * @static
  * @ignore
  */
 public static function __callStatic($method, $args)
 {
     switch ($method) {
         case 'getApiCalls':
             return self::api_calls();
             break;
         case 'setVerbose':
             if (count($args) < 1) {
                 self::$verbose = false;
             } else {
                 self::$verbose = (bool) $args[0];
             }
             break;
         case 'toggleVerbose':
             self::$verbose = !self::$verbose;
             break;
         case 'version':
         case 'getVersion':
             return self::$version;
             break;
         case 'getKey':
         case 'getApiKey':
             return self::$api_key;
             break;
         case 'setKey':
         case 'setApiKey':
             if (count($args) < 1) {
                 self::_set_api_key($args);
             }
             if (is_string($args[0])) {
                 self::$api_key = $args[0];
             } elseif (is_array($args[0])) {
                 self::_set_api_key($args[0]);
             } else {
                 return false;
             }
             return true;
             break;
         case 'getLastError':
             return self::$last_error;
             break;
         case 'call':
             if (count($args) != 1 || !is_array($args[0])) {
                 throw new Exception('Must pass one associative array with proper values set.');
             }
             $args = $args[0];
             return self::_call_api($args);
             break;
     }
 }
 public function __construct($apiKey)
 {
     parent::__construct($apiKey);
 }
Ejemplo n.º 26
-1
 /**
  * Send Bulk Mail via Mandrill
  */
 protected function _mailSendMandrill()
 {
     //-----------------------------------------
     // Load it
     //-----------------------------------------
     $id = intval($this->request['id']);
     $mail = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bulk_mail', 'where' => 'mail_id=' . $id));
     if (!$mail['mail_id'] or !$mail['mail_subject'] or !$mail['mail_content']) {
         $this->registry->output->global_message = $this->lang->words['b_nosend'];
         $this->_mailStart();
         return;
     }
     $opts = unserialize($mail['mail_opts']);
     //-----------------------------------------
     // Work out which vars we've actually used
     //-----------------------------------------
     $usedVars = array('unsubscribe');
     foreach (array_keys($this->_getVariableInformation($this->memberData)) as $k) {
         if (strpos($mail['mail_content'], '{' . $k . '}') !== FALSE) {
             $usedVars[] = $k;
         }
     }
     //-----------------------------------------
     // Build the JSON document
     //-----------------------------------------
     $pergo = 2000;
     $recipientsTo = array();
     $recipientsMerge = array();
     /* Start with a basic query */
     $queryData = array('select' => 'm.*', 'from' => array('members' => 'm'), 'order' => 'm.member_id', 'limit' => array($this->request['st'], $pergo));
     /* Add in filters */
     $done = 0;
     $complete = FALSE;
     $_queryData = $this->_buildMembersQuery($opts['filters']);
     $queryData['add_join'] = $_queryData['add_join'];
     $queryData['where'] = implode(' AND ', $_queryData['where']);
     /* Write the file */
     $this->DB->build($queryData);
     $e = $this->DB->execute();
     if (!$this->DB->getTotalRows($e)) {
         $complete = TRUE;
     }
     while ($r = $this->DB->fetch($e)) {
         /* Skip any invalid emails - the chars presented here are allowed via RFC (note that _ and - are already allowed in alphanumericClean and don't need to be specified) */
         if (!$r['email'] or !$r['members_display_name'] or !IPSText::checkEmailAddress($r['email']) or $r['email'] != IPSText::alphanumericalClean($r['email'], '@.+!#$%&\'*/=?^`{|}~ ')) {
             continue;
         }
         $recipientsTo[] = array('email' => $r['email'], 'name' => $r['members_display_name']);
         $vars = array();
         foreach ($this->_getVariableInformation($r, 1) as $k => $v) {
             if (in_array($k, $usedVars)) {
                 $vars[] = array('name' => $k, 'content' => $v);
             }
         }
         if (!empty($vars)) {
             $recipientsMerge[] = array('rcpt' => $r['email'], 'vars' => $vars);
         }
         $done++;
     }
     //-----------------------------------------
     // Build Content
     //-----------------------------------------
     /* Sort out member vars */
     $content = $mail['mail_content'];
     foreach ($this->_getVariableInformation($this->memberData) as $k => $v) {
         $content = str_replace('{' . $k . '}', '*|' . $k . '|*', $content);
     }
     /* Sort out global vars */
     $globalMergeVars = array();
     foreach ($this->_getVariableInformation(NULL, 2) as $k => $v) {
         if (in_array($k, $usedVars)) {
             $globalMergeVars[] = array('name' => $k, 'content' => $v);
         }
     }
     /* Get the full content */
     IPSText::getTextClass('email')->clearContent();
     IPSText::getTextClass('email')->unsubscribe = true;
     if ($opts['mail_html_on']) {
         IPSText::getTextClass('email')->setHtmlEmail(true);
         IPSText::getTextClass('email')->setHtmlTemplate(str_replace("\n", "", $content));
         IPSText::getTextClass('email')->setHtmlWrapper('<#content#>');
     } else {
         if ($this->settings['email_use_html']) {
             IPSText::getTextClass('email')->setHtmlEmail(true);
             IPSText::getTextClass('email')->setHtmlTemplate($content);
         } else {
             IPSText::getTextClass('email')->setPlainTextTemplate($content, true);
         }
     }
     if ($opts['mail_html_on'] or $this->settings['email_use_html']) {
         IPSText::getTextClass('email')->buildMessage(array('UNSUBSCRIBE' => '*|unsubscribe|*'), true, true);
         $content = IPSText::getTextClass('email')->getHtmlContent();
     } else {
         IPSText::getTextClass('email')->buildMessage(array('UNSUBSCRIBE' => '*|unsubscribe|*'));
         $content = nl2br(IPSText::getTextClass('email')->getPlainTextContent());
     }
     //-----------------------------------------
     // Send to Mandrill
     //-----------------------------------------
     if (IPS_DOC_CHAR_SET != "UTF-8") {
         $mail['mail_subject'] = IPSText::convertCharsets($mail['mail_subject'], IPS_DOC_CHAR_SET, "UTF-8");
     }
     require_once IPSLib::getAppDir('members') . '/sources/classes/mandrill.php';
     $mandrill = new Mandrill();
     $response = $mandrill->messages_send(array('message' => array('html' => $content, 'subject' => $mail['mail_subject'], 'from_email' => $this->settings['email_out'], 'from_name' => $this->settings['board_name'], 'to' => $recipientsTo, 'auto_text' => true, 'url_strip_qs' => false, 'preserve_recipients' => false, 'merge' => true, 'global_merge_vars' => $globalMergeVars, 'merge_vars' => $recipientsMerge, 'tags' => array_merge(array('ips'), array_filter($opts['mandrill_tags'], create_function('$v', 'return (bool) $v;')))), 'async' => true));
     if (isset($response->status) and $response->status == 'error') {
         $this->registry->output->showError('mandrill_error');
     }
     //-----------------------------------------
     // Save
     //-----------------------------------------
     $this->DB->update('bulk_mail', array('mail_active' => 0, 'mail_updated' => time(), 'mail_sentto' => $mail['mail_sentto'] + count($recipientsTo)), 'mail_id=' . $mail['mail_id']);
     if ($complete !== TRUE) {
         $url = "{$this->settings['base_url']}app=members&module=bulkmail&section=bulkmail&do=mail_send_mandrill&id={$id}&countmembers={$this->request['countmembers']}&st=" . ($this->request['st'] + $pergo);
         if (!$this->request['st']) {
             $this->registry->output->multipleRedirectInit($url);
             $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
             $this->registry->getClass('output')->sendOutput();
         } else {
             $percentage = 100 / $this->request['countmembers'] * $this->request['st'];
             $percentage = floor($percentage);
             $this->registry->output->multipleRedirectHit($url, "Processing ({$percentage}% complete)");
         }
         return;
     } else {
         $this->registry->output->multipleRedirectFinish();
     }
 }
Ejemplo n.º 27
-1
 public function __construct($apiKey)
 {
     parent::__construct($apiKey);
     curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE);
 }