src/email.php
public static function send($recipient, $subject, $body, $options=[]) {
	if (empty(self::$mailer)) {
		self::login();
	}
	
	if (ENVIRONMENT != 'production') {
		$recipient = self::protect_emailaddress($recipient);
		if (isset($options['cc'])) {
			$options['cc'] = self::protect_emailaddress($options['cc']);
		}
		if (isset($options['bcc'])) {
			$options['bcc'] = self::protect_emailaddress($options['bcc']);
		}
		if (isset($options['reply_to'])) {
			$options['reply_to'] = self::protect_emailaddress($options['reply_to']);
		}
		
		$subject = '['.ENVIRONMENT.'] '.$subject;
	}
	
	$sender = [self::$config['from'] => self::$config['name']];
	
	$message = new \Swift_Message();
	$message->setFrom($sender);
	$message->setTo($recipient);
	$message->setSubject($subject);
	$message->setBody($body);
	
	if (isset($options['cc'])) {
		$message->setCc($options['cc']);
	}
	if (isset($options['bcc'])) {
		$message->setBcc($options['bcc']);
	}
	if (isset($options['reply_to'])) {
		$message->setReplyTo($options['reply_to']);
	}
	if (isset($options['attachment'])) {
		$attachment = \Swift_Attachment::fromPath($options['attachment']['path'], $options['attachment']['mime']);
		$message->attach($attachment);
	}
	
	self::$mailer->send($message);
}
public static function send($recipient, $subject, $body, $options=[]) {
	if (empty(self::$mailer)) {
		self::login();
	}
	
	if (ENVIRONMENT != 'production') {
		$recipient = self::protect_emailaddress($recipient);
		if (isset($options['cc'])) {
			$options['cc'] = self::protect_emailaddress($options['cc']);
		}
		if (isset($options['bcc'])) {
			$options['bcc'] = self::protect_emailaddress($options['bcc']);
		}
		if (isset($options['reply_to'])) {
			$options['reply_to'] = self::protect_emailaddress($options['reply_to']);
		}
		
		$subject = '['.ENVIRONMENT.'] '.$subject;
	}
	
	$sender = [self::$config['from'] => self::$config['name']];
	
	$message = new \Swift_Message();
	$message->setFrom($sender);
	$message->setTo($recipient);
	$message->setSubject($subject);
	$message->setBody($body);
	
	if (isset($options['cc'])) {
		$message->setCc($options['cc']);
	}
	if (isset($options['bcc'])) {
		$message->setBcc($options['bcc']);
	}
	if (isset($options['reply_to'])) {
		$message->setReplyTo($options['reply_to']);
	}
	if (isset($options['attachment'])) {
		$attachment = \Swift_Attachment::fromPath($options['attachment']['path'], $options['attachment']['mime']);
		$message->attach($attachment);
	}
	
	self::$mailer->send($message);
}
public static function send ( $ recipient , $ subject , $ body , $ options = [ ] ) { if ( empty ( self :: $ mailer ) ) { self :: login ( ) ; } if ( ENVIRONMENT != 'production' ) { $ recipient = self :: protect_emailaddress ( $ recipient ) ; if ( isset ( $ options [ 'cc' ] ) ) { $ options [ 'cc' ] = self :: protect_emailaddress ( $ options [ 'cc' ] ) ; } if ( isset ( $ options [ 'bcc' ] ) ) { $ options [ 'bcc' ] = self :: protect_emailaddress ( $ options [ 'bcc' ] ) ; } if ( isset ( $ options [ 'reply_to' ] ) ) { $ options [ 'reply_to' ] = self :: protect_emailaddress ( $ options [ 'reply_to' ] ) ; } $ subject = '[' . ENVIRONMENT . '] ' . $ subject ; } $ sender = [ self :: $ config [ 'from' ] => self :: $ config [ 'name' ] ] ; $ message = new \ Swift_Message ( ) ; $ message -> setFrom ( $ sender ) ; $ message -> setTo ( $ recipient ) ; $ message -> setSubject ( $ subject ) ; $ message -> setBody ( $ body ) ; if ( isset ( $ options [ 'cc' ] ) ) { $ message -> setCc ( $ options [ 'cc' ] ) ; } if ( isset ( $ options [ 'bcc' ] ) ) { $ message -> setBcc ( $ options [ 'bcc' ] ) ; } if ( isset ( $ options [ 'reply_to' ] ) ) { $ message -> setReplyTo ( $ options [ 'reply_to' ] ) ; } if ( isset ( $ options [ 'attachment' ] ) ) { $ attachment = \ Swift_Attachment :: fromPath ( $ options [ 'attachment' ] [ 'path' ] , $ options [ 'attachment' ] [ 'mime' ] ) ; $ message -> attach ( $ attachment ) ; } self :: $ mailer -> send ( $ message ) ; }
sends an email directly

@todo allow for html emails as well

@param  mixed  $recipient string or [email => name]
@param  string $subject
@param  string $message   plain text only for now
@param  array  $options   array with optional 'cc', 'bcc', 'reply_to', 'attachment' options
'attachment' is expected to be an array with 'path' and 'mime' keys
@return void
sends an email directly