4 require_once
_XE_PATH_ .
"libs/phpmailer/phpmailer.php";
11 class Mail extends PHPMailer
147 $this->SMTPAuth = TRUE;
148 $this->SMTPSecure =
"tls";
149 $this->Host =
'smtp.gmail.com';
153 $this->Username = $account_name;
157 $this->Username = $account_name .
'@gmail.com';
175 function useSMTP($auth = NULL, $host = NULL, $user = NULL, $pass = NULL, $secure = NULL, $port = 25)
177 $this->SMTPAuth = $auth;
179 $this->Username = $user;
183 if($secure ==
'ssl' || $secure ==
'tls')
185 $this->SMTPSecure = $secure;
188 if(($this->SMTPAuth !== NULL && $this->Host !== NULL && $this->Username !== NULL && $this->
Password !== NULL) || ($this->SMTPAuth === NULL && $this->Host !== NULL))
191 $this->AltBody =
"To view the message, please use an HTML compatible email viewer!";
221 $this->attachments[$orgfilename] = $filename;
233 $this->cidAttachments[$cid] = $filename;
245 if($this->Mailer ==
"mail")
247 $this->sender_name = $name;
248 $this->sender_email = $email;
252 $this->SetFrom($email, $name);
263 if(!stristr(PHP_OS,
'win') && $this->sender_name)
265 return sprintf(
"%s <%s>",
'=?utf-8?b?' . base64_encode($this->sender_name) .
'?=', $this->sender_email);
279 if($this->Mailer ==
"mail")
281 $this->receiptor_name = $name;
282 $this->receiptor_email = $email;
286 $this->AddAddress($email, $name);
297 if(!stristr(PHP_OS,
'win') && $this->receiptor_name && $this->receiptor_name != $this->receiptor_email)
299 return sprintf(
"%s <%s>",
'=?utf-8?b?' . base64_encode($this->receiptor_name) .
'?=', $this->receiptor_email);
312 if($this->Mailer ==
"mail")
329 return '=?utf-8?b?' . base64_encode($this->
title) .
'?=';
340 if($this->Mailer ==
"mail")
380 if($this->Mailer ==
"mail")
398 $content = preg_replace_callback(
'/<img([^>]+)>/i', array($this,
'replaceResourceRealPath'),
$content);
399 if($this->Mailer ==
"mail")
428 return chunk_split(base64_encode(str_replace(array(
"<",
">",
"&"), array(
"<",
">",
"&"), $this->
content)));
438 return chunk_split(base64_encode($this->content_type !=
'html' ? nl2br($this->
content) : $this->
content));
449 $this->content_type = $mode ==
'html' ?
'html' :
'';
459 if($this->Mailer ==
"mail")
461 if(count($this->attachments) > 0)
464 $boundary =
'----==' . uniqid(rand(), TRUE);
465 $this->header =
"Content-Type: multipart/mixed;" . $this->eol .
"\tboundary=\"" . $boundary .
"\"" . $this->eol .
$this->eol;
466 $this->body =
"--" . $boundary . $this->eol . $this->body . $this->eol .
$this->eol;
469 foreach($this->attachments as $filename => $attachment)
473 $file_str = $file_handler->readFile($attachment);
474 $chunks = chunk_split(base64_encode($file_str));
476 "--" . $boundary . $this->eol .
477 "Content-Type: %s;" . $this->eol .
478 "\tname=\"%s\"" . $this->eol .
479 "Content-Transfer-Encoding: base64" . $this->eol .
480 "Content-Description: %s" . $this->eol .
481 "Content-Disposition: attachment;" . $this->eol .
482 "\tfilename=\"%s\"" . $this->eol . $this->eol .
483 "%s" . $this->eol . $this->eol, $type, $filename, $filename, $filename, $chunks);
486 $this->body = implode(
"", $res);
487 $this->body .=
"--" . $boundary .
"--";
492 if(count($this->attachments) > 0)
494 foreach($this->attachments as $filename => $attachment)
496 parent::AddAttachment($attachment);
509 if(count($this->cidAttachments) > 0)
512 $boundary =
'----==' . uniqid(rand(), TRUE);
513 $this->header =
"Content-Type: multipart/relative;" . $this->eol .
"\ttype=\"multipart/alternative\";" . $this->eol .
"\tboundary=\"" . $boundary .
"\"" . $this->eol .
$this->eol;
514 $this->body =
"--" . $boundary . $this->eol . $this->body . $this->eol .
$this->eol;
517 foreach($this->cidAttachments as $cid => $attachment)
519 $filename = basename($attachment);
522 $chunks = chunk_split(base64_encode($file_str));
524 "--" . $boundary . $this->eol .
525 "Content-Type: %s;" . $this->eol .
526 "\tname=\"%s\"" . $this->eol .
527 "Content-Transfer-Encoding: base64" . $this->eol .
528 "Content-ID: <%s>" . $this->eol .
529 "Content-Description: %s" . $this->eol .
530 "Content-Location: %s" . $this->eol . $this->eol .
531 "%s" . $this->eol . $this->eol, $type, $filename, $cid, $filename, $filename, $chunks);
534 $this->body = implode(
"", $res);
535 $this->body .=
"--" . $boundary .
"--";
546 if($this->Mailer ==
"mail")
548 $boundary =
'----==' . uniqid(rand(), TRUE);
549 $this->eol =
$GLOBALS[
'_qmail_compatibility'] ==
"Y" ?
"\n" :
"\r\n";
550 $this->header =
"Content-Type: multipart/alternative;" . $this->eol .
"\tboundary=\"" . $boundary .
"\"" . $this->eol .
$this->eol;
551 $this->body = sprintf(
552 "--%s" . $this->eol .
553 "Content-Type: text/plain; charset=utf-8; format=flowed" . $this->eol .
554 "Content-Transfer-Encoding: base64" . $this->eol .
555 "Content-Disposition: inline" . $this->eol . $this->eol .
557 "--%s" . $this->eol .
558 "Content-Type: text/html; charset=utf-8" . $this->eol .
559 "Content-Transfer-Encoding: base64" . $this->eol .
560 "Content-Disposition: inline" . $this->eol . $this->eol .
568 "From: %s" . $this->eol .
573 "MIME-Version: 1.0" . $this->eol .
"", $this->
getSender(), $this->messageId ? (
"Message-ID: <" . $this->messageId .
">" . $this->eol) :
"", $this->replyTo ? (
"Reply-To: <" . $this->replyTo .
">" . $this->eol) :
"", $this->bcc ? (
"Bcc: " . $this->bcc . $this->eol) :
"", $this->references ? (
"References: <" . $this->references .
">" . $this->eol .
"In-Reply-To: <" . $this->references .
">" . $this->eol) :
""
576 if($this->additional_params)
578 return mail($this->
getReceiptor(), $this->
getTitle(), $this->body, $headers, $this->additional_params);
585 return parent::Send();
601 list($user, $host) = explode(
"@", $email_address);
602 if(function_exists(
'checkdnsrr'))
604 if(checkdnsrr($host,
"MX") || checkdnsrr($host,
"A"))
624 if(preg_match(
"/([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/i", $email_address))
626 return $email_address;
642 preg_match(
"|\.([a-z0-9]{2,4})$|i", $filename, $fileSuffix);
643 switch(strtolower($fileSuffix[1]))
646 return "application/x-javascript";
648 return "application/json";
657 return "image/" . strtolower($fileSuffix[1]);
661 return "application/xml";
664 return "application/msword";
673 return "application/vnd.ms-excel";
676 return "application/vnd.ms-powerpoint";
678 return "application/rtf";
680 return "application/pdf";
692 return "audio/mpeg3";
699 return "video/msvideo";
701 return "video/x-ms-wmv";
703 return "video/quicktime";
705 return "application/zip";
707 return "application/x-tar";
709 return "application/x-shockwave-flash";
711 if(function_exists(
"mime_content_type"))
713 $fileSuffix = mime_content_type($filename);
715 return "unknown/" . trim($fileSuffix[0],
".");
addAttachment($filename, $orgfilename)
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
checkMailMX($email_address)
setReceiptor($name, $email)
isVaildMailAddress($email_address)
setReferences($references)
widget to display content
returnMIMEType($filename)
useSMTP($auth=NULL, $host=NULL, $user=NULL, $pass=NULL, $secure=NULL, $port=25)
useGmailAccount($account_name, $account_passwd)
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
addCidAttachment($filename, $cid)
replaceResourceRealPath($matches)
setAdditionalParams($additional_params)
setContentType($mode= 'html')