function sendEmail() { $secretkey = $_REQUEST['secretkey']; require_once 'lib/phpmailer/class.phpmailer.php'; $reply = array(); if ($_SESSION['email_secretkey'] && $secretkey == $_SESSION['email_secretkey']) { $_SESSION['email_secretkey'] = ''; $destination = $_REQUEST['destination']; $subject = $_REQUEST['subject']; $content = $_REQUEST['content']; $replyto = strip_tags($_SESSION['email_replyto']); $fromname = strip_tags($_SESSION['email_fromname']); $mail = new PHPMailer(); $mail->PluginDir = "lib/phpmailer/"; $mail->SetLanguage("en", "lib/phpmailer/language/"); $mail->CharSet = "UTF-8"; $mail->From = $replyto; $mail->FromName = $fromname; $mail->AddAddress($destination); if (SMTP_HOST) { $mail->Host = SMTP_HOST; $mail->Mailer = "smtp"; $mail->SMTPAuth = SMTP_LOGIN != ''; $mail->Username = SMTP_LOGIN; $mail->Password = SMTP_PASSWORD; } $mail->IsHTML(false); $mail->Subject = $subject; $mail->Body = $content; $rc = $mail->Send(); if (!$rc) { $reply['error'] = $mail->ErrorInfo; } else { save_email_address($this->link, db_escape_string($destination)); $reply['message'] = "UPDATE_COUNTERS"; } } else { $reply['error'] = "Not authorized."; } print json_encode($reply); }
function sendEmail() { require_once 'classes/ttrssmailer.php'; $reply = array(); $mail = new ttrssMailer(); $mail->From = strip_tags($_REQUEST['from_email']); $mail->FromName = strip_tags($_REQUEST['from_name']); //$mail->AddAddress($_REQUEST['destination']); $addresses = explode(';', $_REQUEST['destination']); foreach ($addresses as $nextaddr) { $mail->AddAddress($nextaddr); } $mail->IsHTML(false); $mail->Subject = $_REQUEST['subject']; $mail->Body = $_REQUEST['content']; $rc = $mail->Send(); if (!$rc) { $reply['error'] = $mail->ErrorInfo; } else { save_email_address(db_escape_string($destination)); $reply['message'] = "UPDATE_COUNTERS"; } print json_encode($reply); }