Location: PHPKode > projects > Open Media Collectors Database > functions/opendbmailer.class.php
<?php
/* 	
 	Open Media Collectors Database
	Copyright (C) 2001,2006 by Jason Pell

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

require_once('./functions/phpmailer/class.phpmailer.php');
// hardcoded to english messages for now
include_once("./functions/phpmailer/language/phpmailer.lang-en.php");

include_once("./functions/config.php");
include_once("./functions/logging.php");

/**
	If set to email.mailer = 'mail', then must provide extra details:
		email.smtp.host
        email.smtp.port
		email.smtp.username
		email.smtp.password
*/
class OpenDbMailer extends PHPMailer
{
	function OpenDbMailer($mailer)
	{
		$this->PluginDir = './functions/phpmailer/';
		
		if(get_opendb_config_var('email', 'windows_smtp_server')===TRUE)
		{
        	$this->LE = "\r\n";
		}
		else
		{
			$this->LE = "\n";
		}
		
        $this->Mailer = $mailer;
        $this->Priority = "3"; // in case we want to change it
        $this->Sender = get_opendb_config_var('email', 'noreply_address');

		if($this->Mailer == 'smtp')
		{
    		$email_smtp_r = get_opendb_config_var('email.smtp');

    		// at least host should be defined.
			if(is_not_empty_array($email_smtp_r) && strlen($email_smtp_r['host'])>0)
			{
            	$this->Host = $email_smtp_r['host'];

				if(strlen($email_smtp_r['port'])>0)
					$this->Port = $email_smtp_r['port'];
    	        if(strlen($email_smtp_r['username'])>0)
					$this->Username = $email_smtp_r['username'];
            	if(strlen($email_smtp_r['port'])>0)
					$this->Password = $email_smtp_r['password'];
			}
			else
			{
			    // set to 'mail' mailer as default, and log configuration error.
			    opendb_logger(OPENDB_LOG_ERROR,  __FILE__, __FUNCTION__, 'Email SMTP Configuration missing', array($mailer));

				// override, because mailer smtp is misconfigured.
			    $this->Mailer = 'mail';
			}
		}
	}
	
	/**
	    Language variables are hardcoded to english at the moment.
	*/
	function Lang($key)
	{
		global $PHPMAILER_LANG;
		
		if(isset($PHPMAILER_LANG[$key]))
            return $PHPMAILER_LANG[$key];
        else
            return "Language string failed to load: " . $key;
	}
}
?>
Return current item: Open Media Collectors Database