<?php
/**
 * @version $Id: mail.inc.php v2.0 $
 * @package PBDigg
 * @copyright Copyright (C) 2007 - 2008 PBDigg.com. All Rights Reserved.
 * @license PBDigg is free software and use is subject to license terms
 */

if (!defined('IN_PBDIGG'))
{
	exit('Access Denied!');
}

require_once (PBDIGG_ROOT.'include/phpmailer/class.phpmailer.php');

$mail = new PHPMailer();

if ($pb_mailtype)
{
	$mail->IsSMTP();
	$mail->Host = $pb_smtphost;
	if ($pb_smtpauth)
	{
		$mail->SMTPAuth = TRUE;
	}
	$mail->Username = $pb_smtpuser;
	$mail->Password = $pb_smtppw;
	if ($pb_smtpport)
	{
		$mail->Port = $pb_smtpport;
	}
}
else
{
	$mail->IsMail();
}
$mail->From = $pb_smtpuser;
$mail->FromName = $pb_sitename;
$mail->CharSet = $db_charset;
$mail->Encoding = 'base64';
$mail->IsHTML(TRUE);
$mail->AltBody ='To view the message, please use an HTML compatible email viewer!';

function PMail($sendto, $subject, $body)
{
    global $mail;
	$mail->AddAddress($sendto);
	$mail->Subject = $subject;
	$mail->Body = $body;
	if($mail->Send())
	{
		return TRUE;
	} 
	else
	{
		return $mail->ErrorInfo;
	}
}
?>
