protected static function getMailTransport() {
		if(!isset(PhpReports::$config['mail_settings'])) PhpReports::$config['mail_settings'] = array();
		if(!isset(PhpReports::$config['mail_settings']['method'])) PhpReports::$config['mail_settings']['method'] = 'mail';
		
		switch(PhpReports::$config['mail_settings']['method']) {
			case 'mail':
				return Swift_MailTransport::newInstance();
			case 'sendmail':
				return Swift_MailTransport::newInstance(
					isset(PhpReports::$config['mail_settings']['command'])? PhpReports::$config['mail_settings']['command'] : '/usr/sbin/sendmail -bs'
				);
			case 'smtp':
				if(!isset(PhpReports::$config['mail_settings']['server'])) throw new Exception("SMTP server must be configured");
				$transport = Swift_SmtpTransport::newInstance(
					PhpReports::$config['mail_settings']['server'],
					isset(PhpReports::$config['mail_settings']['port'])? PhpReports::$config['mail_settings']['port'] : 25
				);
				
				//if username/password
				if(isset(PhpReports::$config['mail_settings']['username'])) {
					$transport->setUsername(PhpReports::$config['mail_settings']['username']);
					$transport->setPassword(PhpReports::$config['mail_settings']['password']);
				}
				
				//if using encryption
				if(isset(PhpReports::$config['mail_settings']['encryption'])) {
					$transport->setEncryption(PhpReports::$config['mail_settings']['encryption']);
				}
				
				return $transport;
			default:
				throw new Exception("Mail method must be either 'mail', 'sendmail', or 'smtp'");
		}
	}
protected static function getMailTransport() {
		if(!isset(PhpReports::$config['mail_settings'])) PhpReports::$config['mail_settings'] = array();
		if(!isset(PhpReports::$config['mail_settings']['method'])) PhpReports::$config['mail_settings']['method'] = 'mail';
		
		switch(PhpReports::$config['mail_settings']['method']) {
			case 'mail':
				return Swift_MailTransport::newInstance();
			case 'sendmail':
				return Swift_MailTransport::newInstance(
					isset(PhpReports::$config['mail_settings']['command'])? PhpReports::$config['mail_settings']['command'] : '/usr/sbin/sendmail -bs'
				);
			case 'smtp':
				if(!isset(PhpReports::$config['mail_settings']['server'])) throw new Exception("SMTP server must be configured");
				$transport = Swift_SmtpTransport::newInstance(
					PhpReports::$config['mail_settings']['server'],
					isset(PhpReports::$config['mail_settings']['port'])? PhpReports::$config['mail_settings']['port'] : 25
				);
				
				//if username/password
				if(isset(PhpReports::$config['mail_settings']['username'])) {
					$transport->setUsername(PhpReports::$config['mail_settings']['username']);
					$transport->setPassword(PhpReports::$config['mail_settings']['password']);
				}
				
				//if using encryption
				if(isset(PhpReports::$config['mail_settings']['encryption'])) {
					$transport->setEncryption(PhpReports::$config['mail_settings']['encryption']);
				}
				
				return $transport;
			default:
				throw new Exception("Mail method must be either 'mail', 'sendmail', or 'smtp'");
		}
	}
protected static function getMailTransport ( ) { if ( ! isset ( PhpReports :: $ config [ 'mail_settings' ] ) ) PhpReports :: $ config [ 'mail_settings' ] = array ( ) ; if ( ! isset ( PhpReports :: $ config [ 'mail_settings' ] [ 'method' ] ) ) PhpReports :: $ config [ 'mail_settings' ] [ 'method' ] = 'mail' ; switch ( PhpReports :: $ config [ 'mail_settings' ] [ 'method' ] ) { case 'mail' : return Swift_MailTransport :: newInstance ( ) ; case 'sendmail' : return Swift_MailTransport :: newInstance ( isset ( PhpReports :: $ config [ 'mail_settings' ] [ 'command' ] ) ? PhpReports :: $ config [ 'mail_settings' ] [ 'command' ] : '/usr/sbin/sendmail -bs' ) ; case 'smtp' : if ( ! isset ( PhpReports :: $ config [ 'mail_settings' ] [ 'server' ] ) ) throw new Exception ( "SMTP server must be configured" ) ; $ transport = Swift_SmtpTransport :: newInstance ( PhpReports :: $ config [ 'mail_settings' ] [ 'server' ] , isset ( PhpReports :: $ config [ 'mail_settings' ] [ 'port' ] ) ? PhpReports :: $ config [ 'mail_settings' ] [ 'port' ] : 25 ) ; //if username/password if ( isset ( PhpReports :: $ config [ 'mail_settings' ] [ 'username' ] ) ) { $ transport -> setUsername ( PhpReports :: $ config [ 'mail_settings' ] [ 'username' ] ) ; $ transport -> setPassword ( PhpReports :: $ config [ 'mail_settings' ] [ 'password' ] ) ; } //if using encryption if ( isset ( PhpReports :: $ config [ 'mail_settings' ] [ 'encryption' ] ) ) { $ transport -> setEncryption ( PhpReports :: $ config [ 'mail_settings' ] [ 'encryption' ] ) ; } return $ transport ; default : throw new Exception ( "Mail method must be either 'mail', 'sendmail', or 'smtp'" ) ; } }
Determines the email transport to use based on the configuration settings
Determines the email transport to use based on the configuration settings