public function send(Swift_Mime_Message $message, &$failedRecipients=null)
	{
		try
		{
			// Start building the message
			$from = $message->getFrom();
			$to   = [];

			// Process recipients
			foreach ($message->getTo() as $address => $name)
			{
				$to[] = [
					'email' => $address,
					'name'  => $name,
					'type'  => 'to'
				];
			}

			// Check for attachments
			$attachments = [];
			$html        = '';
			$txt         = '';

			foreach ($message->getChildren() as $children)
			{
				if ($children instanceof Swift_Attachment)
				{
					$attachments[] = [
						'type'    => $children->getContentType(),
						'name'    => $children->getFilename(),
						'content' => base64_encode($children->getBody())
					];
				}
				elseif ($message->getBody() == null)
				{
					if ($children->getContentType() == 'text/html')
					{
						$html .= $children->getBody();
					}
					else
					{
						$txt .= $children->getBody();
					}
				}
				else
				{
					if ($message->getContentType() == 'text/html')
					{
						$html .= $message->getBody();
					}
					else
					{
						$txt .= $message->getBody();
					}
				}
			}

			// Build message
			$mail = [
				'html'                => $html,
				'txt'                 => $txt,
				'subject'             => $message->getSubject(),
				'from_email'          => array_keys($from)[0],
				'from_name'           => reset($from),
				'to'                  => $to,
				'headers'             => array('Reply-To' => $message->getReplyTo()),
				'attachments'         => $attachments,
				'tags'                => $message->getTags(),
				'preserve_recipients' => false,
			];

			// @FIXME: could paramertize some of these options
			$async   = false;
			$ip_pool = 'Main Pool';
			$result  = $this->mandrill->messages->send($mail, $async, $ip_pool);

			// Check for issues in sending
			foreach ($result as $recepient)
			{
				if (!in_array($recepient['status'], ['queued', 'sent']))
				{
					\Log::info(\Lang::txt('Mail to %s failed', $recepient['email']));
				}
			}

			return true;
		}
		catch (Mandrill_Error $e)
		{
			throw new RuntimeException('A mandrill error occurred: ' . $e->getMessage(), 500);
		}
	}
public function send(Swift_Mime_Message $message, &$failedRecipients=null)
	{
		try
		{
			// Start building the message
			$from = $message->getFrom();
			$to   = [];

			// Process recipients
			foreach ($message->getTo() as $address => $name)
			{
				$to[] = [
					'email' => $address,
					'name'  => $name,
					'type'  => 'to'
				];
			}

			// Check for attachments
			$attachments = [];
			$html        = '';
			$txt         = '';

			foreach ($message->getChildren() as $children)
			{
				if ($children instanceof Swift_Attachment)
				{
					$attachments[] = [
						'type'    => $children->getContentType(),
						'name'    => $children->getFilename(),
						'content' => base64_encode($children->getBody())
					];
				}
				elseif ($message->getBody() == null)
				{
					if ($children->getContentType() == 'text/html')
					{
						$html .= $children->getBody();
					}
					else
					{
						$txt .= $children->getBody();
					}
				}
				else
				{
					if ($message->getContentType() == 'text/html')
					{
						$html .= $message->getBody();
					}
					else
					{
						$txt .= $message->getBody();
					}
				}
			}

			// Build message
			$mail = [
				'html'                => $html,
				'txt'                 => $txt,
				'subject'             => $message->getSubject(),
				'from_email'          => array_keys($from)[0],
				'from_name'           => reset($from),
				'to'                  => $to,
				'headers'             => array('Reply-To' => $message->getReplyTo()),
				'attachments'         => $attachments,
				'tags'                => $message->getTags(),
				'preserve_recipients' => false,
			];

			// @FIXME: could paramertize some of these options
			$async   = false;
			$ip_pool = 'Main Pool';
			$result  = $this->mandrill->messages->send($mail, $async, $ip_pool);

			// Check for issues in sending
			foreach ($result as $recepient)
			{
				if (!in_array($recepient['status'], ['queued', 'sent']))
				{
					\Log::info(\Lang::txt('Mail to %s failed', $recepient['email']));
				}
			}

			return true;
		}
		catch (Mandrill_Error $e)
		{
			throw new RuntimeException('A mandrill error occurred: ' . $e->getMessage(), 500);
		}
	}
public function send ( Swift_Mime_Message $ message , & $ failedRecipients = null ) { try { // Start building the message $ from = $ message -> getFrom ( ) ; $ to = [ ] ; // Process recipients foreach ( $ message -> getTo ( ) as $ address => $ name ) { $ to [ ] = [ 'email' => $ address , 'name' => $ name , 'type' => 'to' ] ; } // Check for attachments $ attachments = [ ] ; $ html = '' ; $ txt = '' ; foreach ( $ message -> getChildren ( ) as $ children ) { if ( $ children instanceof Swift_Attachment ) { $ attachments [ ] = [ 'type' => $ children -> getContentType ( ) , 'name' => $ children -> getFilename ( ) , 'content' => base64_encode ( $ children -> getBody ( ) ) ] ; } elseif ( $ message -> getBody ( ) == null ) { if ( $ children -> getContentType ( ) == 'text/html' ) { $ html .= $ children -> getBody ( ) ; } else { $ txt .= $ children -> getBody ( ) ; } } else { if ( $ message -> getContentType ( ) == 'text/html' ) { $ html .= $ message -> getBody ( ) ; } else { $ txt .= $ message -> getBody ( ) ; } } } // Build message $ mail = [ 'html' => $ html , 'txt' => $ txt , 'subject' => $ message -> getSubject ( ) , 'from_email' => array_keys ( $ from ) [ 0 ] , 'from_name' => reset ( $ from ) , 'to' => $ to , 'headers' => array ( 'Reply-To' => $ message -> getReplyTo ( ) ) , 'attachments' => $ attachments , 'tags' => $ message -> getTags ( ) , 'preserve_recipients' => false , ] ; // @FIXME: could paramertize some of these options $ async = false ; $ ip_pool = 'Main Pool' ; $ result = $ this -> mandrill -> messages -> send ( $ mail , $ async , $ ip_pool ) ; // Check for issues in sending foreach ( $ result as $ recepient ) { if ( ! in_array ( $ recepient [ 'status' ] , [ 'queued' , 'sent' ] ) ) { \ Log :: info ( \ Lang :: txt ( 'Mail to %s failed' , $ recepient [ 'email' ] ) ) ; } } return true ; } catch ( Mandrill_Error $ e ) { throw new RuntimeException ( 'A mandrill error occurred: ' . $ e -> getMessage ( ) , 500 ) ; } }
Sends the given message

Recipient/sender data will be retrieved from the Message API.
The return value is the number of recipients who were accepted for delivery.

@param   object  $message           The message to be sent
@param   array   $failedRecipients  An array of failures
@return  int
Sends the given message