1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195:
<?php
class PHPShopMail {
var $codepage = "windows-1251";
var $type = "text/plain";
var $debug = false;
function __construct($to, $from, $subject, $content, $type = false, $noSend = false, $option = false) {
global $PHPShopSystem, $_classPath;
if (empty($_classPath))
$_classPath = './phpshop/';
require_once $_classPath . 'lib/phpmailer/PHPMailerAutoload.php';
$this->mail = new PHPMailer;
$this->PHPShopSystem = $PHPShopSystem;
$option = $this->PHPShopSystem->getMailOption($option);
$GLOBALS['SysValue']['other']['serverPath'] = $_SERVER['SERVER_NAME'] . "/" . $GLOBALS['SysValue']['dir']['dir'];
if (is_array($option)) {
if (!empty($option['replyto']))
$this->mail->addReplyTo($option['replyto']);
if ($option['smtp'] == true) {
$this->mail->isSMTP();
$this->mail->SMTPDebug = $option['debug'];
$this->mail->Debugoutput = 'html';
$this->mail->Host = $option['host'];
$this->mail->Port = $option['port'];
$this->SMTPSecure = $option['tls'];
$this->mail->SMTPAuth = $option['auth'];
$this->mail->Username = $option['user'];
$this->mail->Password = $option['password'];
if (!empty($option['auth']))
$this->mail->SMTPAuth = true;
if ($this->debug)
$this->mail->SMTPDebug = 2;
}
elseif ($option['sendmail'] == true) {
$this->mail->isMail();
}
} else {
$this->mail->isMail();
}
$this->mail->XMailer = 'PHPShop';
$this->mail->CharSet = $this->codepage;
if (!empty($type)) {
$this->type = 'text/html';
$this->mail->isHTML(true);
$this->mail->msgHTML($content);
} else {
$this->mail->isHTML(false);
$this->mail->Body = $content;
}
if (strstr($from, ',')) {
$from_array = explode(",", $from);
$this->from = trim($from_array[0]);
}
else
$this->from = $from;
$this->mail->setFrom($this->from, $PHPShopSystem->getName());
if (strstr($to, ',')) {
$to_array = explode(",", $from);
if (is_array($to_array)) {
foreach ($to_array as $k => $mail)
if ($k == 0)
$this->mail->addAddress($mail);
else
$this->mail->addBCC($mail);
}
}
else
$this->mail->addAddress($to);
$this->mail->Subject = $subject;
if (empty($noSend)) {
$this->sendMail();
} else {
$this->setOrgData();
}
}
function setOrgData() {
if ($this->PHPShopSystem) {
$GLOBALS['SysValue']['other']['adminMail'] = $this->PHPShopSystem->getEmail();
$GLOBALS['SysValue']['other']['telNum'] = $this->PHPShopSystem->getParam('tel');
$GLOBALS['SysValue']['other']['org_name'] = $this->PHPShopSystem->getSerilizeParam('bank.org_name');
$GLOBALS['SysValue']['other']['org_adres'] = $this->PHPShopSystem->getSerilizeParam('bank.org_adres');
$GLOBALS['SysValue']['other']['logo'] = $this->PHPShopSystem->getParam('logo');
$GLOBALS['SysValue']['other']['shopName'] = $this->PHPShopSystem->getName();
$GLOBALS['SysValue']['other']['serverPath'] = $_SERVER['SERVER_NAME'] . "/" . $GLOBALS['SysValue']['dir']['dir'];
$GLOBALS['SysValue']['other']['date'] = date("d-m-y H:i a");
}
}
function sendMailNow($content) {
$this->mail->msgHTML($content);
$result = $this->mail->send();
if (!$result and $this->debug) {
echo "Mailer Error: " . $this->mail->ErrorInfo;
} elseif ($this->debug) {
echo "Message sent!";
}
return $result;
}
function sendMail() {
$result = $this->mail->send();
if (!$result and $this->debug) {
echo "Mailer Error: " . $this->mail->ErrorInfo;
} elseif ($this->debug) {
echo "Message sent!";
}
return $result;
}
}
class PHPShopMailFile extends PHPShopMail {
function __construct($to, $from, $subject, $content, $filename, $file, $option = false) {
parent::__construct($to, $from, $subject, $content, true, true, $option);
$this->mail->addAttachment($file, $filename);
$this->sendMailNow($content);
}
}
?>