* @copyright 2008 Sam Bauers * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v2 * @version 0.1 **/ class BB_SMTP_Mailer { /* SETTINGS */ // Set to 'smtp' to use an SMTP server var $mailer = 'smtp'; // Set a specific name that emails will appear to come from var $from_name = ''; // The hostname of the SMTP server var $smtp_host = 'localhost'; // The port (default is 25) var $smtp_port = 25; // Use authentication (true or false) var $smtp_auth = false; // Authentication user var $smtp_user = ''; // Athentication password var $smtp_pass = ''; /* END SETTINGS */ function BB_SMTP_Mailer() { add_filter('bb_mail_from_name', array(&$this, 'inject_from_name')); add_action('bb_phpmailer_init', array(&$this, 'inject_smtp_setting')); } function inject_from_name($unfiltered_name) { if ($this->from_name) { return $this->from_name; } else { return $unfiltered_name; } } function inject_smtp_setting($mailer_object) { if (!$mailer_object || !is_object($mailer_object) || !is_a($mailer_object, 'PHPMailer')) { return false; } if ($this->mailer == 'smtp') { $mailer_object->Mailer = $this->mailer; $mailer_object->Host = $this->smtp_host; if ($this->smtp_port) { $mailer_object->Port = $this->smtp_port; } if ($this->smtp_auth) { $mailer_object->SMTPAuth = true; $mailer_object->Username = $this->smtp_user; $mailer_object->Password = $this->smtp_pass; } } } } $bb_smtp_mailer = new BB_SMTP_Mailer(); ?>