00001 <?php
00002
00003 class aliroMailer extends htmlMimeMail5 {
00004 protected $Mailer = '';
00005 private $config = null;
00006 private $body = '';
00007
00008 public function __construct () {
00009 parent::__construct();
00010 $this->configureHtmlMimeMail5 ();
00011 }
00012
00013 private function getCfg ($property) {
00014 static $config = null;
00015 if (null === $config) $config = aliroCore::getInstance();
00016 return $config->getCfg($property);
00017 }
00018
00019 private function configureHtmlMimeMail5 () {
00020 $this->setTextCharset(substr_replace(_ISO, '', 0, 8));
00021 $this->Mailer = $this->getCfg('mailer');
00022 $sendmail = $this->getCfg('sendmail');
00023
00024 if ($this->Mailer == 'smtp') {
00025 $config = aliroCore::getInstance();
00026 $auth = $config->getCfg('smtpauth');
00027 $user = $config->getCfg('smtpuser');
00028 $pass = $config->getCfg('smtppass');
00029 $host = $config->getCfg('smtphost');
00030 $port = null;
00031 $helo = null;
00032 $this->setSMTPParams($host, $port, $helo, $auth, $user, $pass);
00033 }
00034
00035 elseif ($this->Mailer == 'sendmail' AND $sendmail) $this->setSendmailPath($sendmail);
00036 }
00037
00038 }
00039
00040 class mosMailer extends aliroMailer {
00041 private $body = '';
00042
00051 public function __construct ( $from='', $fromname='', $subject, $body ) {
00052 parent::__construct();
00053 $config = aliroCore::getInstance();
00054 $fromemail = $from ? $from : $config->getCfg('mailfrom');
00055 $fromname = $fromname ? $fromname : $config->getCfg('fromname');
00056 $from = "$fromname <$fromemail>";
00057 $this->setFrom ($from);
00058 $this->setSubject($subject);
00059 $this->body = $body;
00060
00061 }
00062
00077 function mosMail($recipient, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) {
00078
00079 if ($mode) $this->setHTML($this->body);
00080 else $this->setText($this->body);
00081 if(!is_array($recipient)) $recipient = array($recipient);
00082 if (isset($cc)) {
00083 if (is_array($cc)) foreach ($cc as $to) $this->setCC($to);
00084 else $this->setCC($cc);
00085 }
00086 if (isset($bcc)) {
00087 if(is_array($bcc)) foreach ($bcc as $to) $this->setBCC($to);
00088 else $this->setBCC($bcc);
00089 }
00090 if ($attachment) {
00091 if (is_array($attachment)) foreach ($attachment as $fname) $this->addAttachment($fname);
00092 else $this->addAttachment($attachment);
00093 }
00094 if ($replyto) {
00095 if (is_array($replyto)) {
00096 foreach ($replyto as $to) {
00097 $toname = ((list($key, $value) = each($replytoname))
00098 ? $value : "");
00099
00100 }
00101 }
00102 }
00103 $result = $this->Send($recipient, $this->Mailer);
00104 $my = aliroUser::getInstance();
00105 $database = aliroCoreDatabase::getInstance();
00106 if (is_array($recipient)) {
00107 foreach ($recipient as &$rec) $rec= $database->getEscaped($rec);
00108 $recipient = implode (' / ', $recipient);
00109 }
00110 else $recipient = $database->getEscaped($recipient);
00111 $posted = $database->getEscaped(serialize($_POST));
00112 $userid = (string) $my->id;
00113 $database->doSQL("INSERT INTO `#__mail_log` VALUES (0, $userid, NOW(), '$this->Mailer', '$recipient', '{$_SERVER['REQUEST_URI']}', '$posted')");
00114 $database->doSQL("DELETE LOW_PRIORITY FROM `#__mail_log` WHERE date < SUBDATE(NOW(), INTERVAL 7 DAY)");
00115 return $result;
00116 }
00117
00118 }
00119
00120 ?>