Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Geeklog-Core/geeklog
Browse files Browse the repository at this point in the history
  • Loading branch information
dengenxp committed Nov 1, 2016
2 parents 16dc953 + 216e1bf commit 83935fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 105 deletions.
14 changes: 7 additions & 7 deletions public_html/lib-common.php
Expand Up @@ -3796,18 +3796,18 @@ function COM_makesid()
*/
function COM_isEmail($email)
{
require_once 'Mail/RFC822.php';
// This regular expression was taken from Pear's Mail/RFC822.php
$isMatch = preg_match('/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i', trim($email));

$rfc822 = new Mail_RFC822;

return $rfc822->isValidInetAddress($email);
return ($isMatch === 1);
}

/**
* Encode a string such that it can be used in an email header
*
* @param string $string the text to be encoded
* @return string encoded text
* @param string $string the text to be encoded
* @return string encoded text
* @deprecated since Geeklog-2.1.2
*/
function COM_emailEscape($string)
{
Expand Down Expand Up @@ -3887,7 +3887,7 @@ function COM_formatEmailAddress($name, $address)
*/
function COM_mail($to, $subject, $message, $from = '', $html = false, $priority = 0, $optional = null, array $attachments = array())
{
return \Geeklog\Mail::send($to, $subject, $message, $from, $html, $priority, $optional, $attachments);
return Geeklog\Mail::send($to, $subject, $message, $from, $html, $priority, $optional, $attachments);
}

/**
Expand Down
102 changes: 4 additions & 98 deletions system/classes/dbbackup.class.php
Expand Up @@ -506,104 +506,13 @@ private function SendMail(
$altBody = '',
$attachments = array()
) {
global $_CONF;

$subject = substr($subject, 0, strcspn($subject, "\r\n"));
$subject = COM_emailEscape($subject);

require_once $_CONF['path'] . 'lib/phpmailer/class.phpmailer.php';

$mail = new PHPMailer();
$mail->SetLanguage('en',$_CONF['path'].'lib/phpmailer/language/');
$mail->CharSet = COM_getCharset();
if ($_CONF['mail_backend'] == 'smtp') {
$mail->IsSMTP();
$mail->Host = $_CONF['mail_smtp_host'];
$mail->Port = $_CONF['mail_smtp_port'];
if ($_CONF['mail_smtp_secure'] != 'none') {
$mail->SMTPSecure = $_CONF['mail_smtp_secure'];
}
if ($_CONF['mail_smtp_auth']) {
$mail->SMTPAuth = true;
$mail->Username = $_CONF['mail_smtp_username'];
$mail->Password = $_CONF['mail_smtp_password'];
}
$mail->Mailer = "smtp";

} elseif ($_CONF['mail_backend'] == 'sendmail') {
$mail->Mailer = "sendmail";
$mail->Sendmail = $_CONF['mail_sendmail_path'];
} else {
$mail->Mailer = "mail";
}
$mail->WordWrap = 76;
$mail->IsHTML($html);
if ($html) {
$mail->Body = COM_filterHTML($message);
} else {
$mail->Body = $message;
}

if ($altBody != '') {
$mail->AltBody = $altBody;
}
$options = array();

$mail->Subject = $subject;

if (is_array($from) && isset($from[0]) && $from[0] != '') {
if ($_CONF['use_from_site_mail'] == 1) {
$mail->From = $_CONF['site_mail'];
$mail->AddReplyTo($from[0]);
} else {
$mail->From = $from[0];
}
} else {
$mail->From = $_CONF['site_mail'];
if (!empty($cc)) {
$options['cc'] = $cc;
}

if (is_array($from) && isset($from[1]) && $from[1] != '') {
$mail->FromName = $from[1];
} else {
$mail->FromName = $_CONF['site_name'];
}
if (is_array($to) && isset($to[0]) && $to[0] != '') {
if (isset($to[1]) && $to[1] != '') {
$mail->AddAddress($to[0],$to[1]);
} else {
$mail->AddAddress($to[0]);
}
} else {
// assume old style....
$mail->AddAddress($to);
}

if (isset($cc[0]) && $cc[0] != '') {
if (isset($cc[1]) && $cc[1] != '') {
$mail->AddCC($cc[0],$cc[1]);
} else {
$mail->AddCC($cc[0]);
}
} else {
// assume old style....
if (isset($cc) && $cc != '') {
$mail->AddCC($cc);
}
}

if ($priority) {
$mail->Priority = 1;
}

// Add attachments
foreach($attachments as $key => $value) {
$mail->AddAttachment($value);
}

if(!$mail->Send()) {
COM_errorLog("Email Error: " . $mail->ErrorInfo);
return false;
}
return true;
return COM_mail($to, $subject, $message, $from, $html, $priority, $options, $attachments);
}


Expand Down Expand Up @@ -722,6 +631,3 @@ public function Purge($files = 0)
}

} // class dbBackup


?>

0 comments on commit 83935fe

Please sign in to comment.