X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=plugins%2Fmail%2Finit.php;h=21b58d73721b298c27d368705e1d62e10d9e98c1;hb=6d194d85415dee671c0afa2e734292743920f1a2;hp=a4817a15d11450f0a8100b998277902d0e68c6b9;hpb=707ad6ddf7b199e202fc39f61ffd08a4bc5bacc1;p=tt-rss.git diff --git a/plugins/mail/init.php b/plugins/mail/init.php index a4817a15..21b58d73 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -1,7 +1,6 @@ link = $host->get_link(); $this->host = $host; $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + $host->add_hook($host::HOOK_PREFS_TAB, $this); } function get_js() { return file_get_contents(dirname(__FILE__) . "/mail.js"); } + function save() { + $addresslist = db_escape_string($_POST["addresslist"]); + + $this->host->set($this, "addresslist", $addresslist); + + echo __("Mail addresses saved."); + } + + function hook_prefs_tab($args) { + if ($args != "prefPrefs") return; + + print "
" . __("You can set predefined email addressed here (comma-separated list):") . "
"; + + print ""; + + print ""; - print __('From:'); - - print " | "; - - print "\">"; - - print " |
"; + $addresslist = explode(",", $this->host->get($this, "addresslist")); print __('To:'); print " | "; - print ""; + name=\"destination\" id=\"emailArticleDlg_destination\">"; */ + + print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.FilteringSelect"'); - print ""; +/* print ""; */ print " |
";
@@ -135,65 +176,36 @@ class Mail extends Plugin {
}
function sendEmail() {
- $secretkey = $_REQUEST['secretkey'];
-
- require_once 'lib/phpmailer/class.phpmailer.php';
+ require_once 'classes/ttrssmailer.php';
$reply = array();
- if ($_SESSION['email_secretkey'] &&
- $secretkey == $_SESSION['email_secretkey']) {
-
- $_SESSION['email_secretkey'] = '';
-
- $destination = $_REQUEST['destination'];
- $subject = $_REQUEST['subject'];
- $content = $_REQUEST['content'];
+ $mail = new ttrssMailer();
- $replyto = strip_tags($_SESSION['email_replyto']);
- $fromname = strip_tags($_SESSION['email_fromname']);
+ $mail->AddReplyTo(strip_tags($_REQUEST['from_email'], $_REQUEST['from_name']));
+ //$mail->AddAddress($_REQUEST['destination']);
+ $addresses = explode(';', $_REQUEST['destination']);
+ foreach($addresses as $nextaddr)
+ $mail->AddAddress($nextaddr);
- $mail = new PHPMailer();
+ $mail->IsHTML(false);
+ $mail->Subject = $_REQUEST['subject'];
+ $mail->Body = $_REQUEST['content'];
- $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($this->link, $destination));
- $reply['message'] = "UPDATE_COUNTERS";
- }
+ $rc = $mail->Send();
+ if (!$rc) {
+ $reply['error'] = $mail->ErrorInfo;
} else {
- $reply['error'] = "Not authorized.";
+ //save_email_address(db_escape_string($destination));
+ $reply['message'] = "UPDATE_COUNTERS";
}
print json_encode($reply);
}
- function completeEmails() {
- $search = db_escape_string($this->link, $_REQUEST["search"]);
+ /* function completeEmails() {
+ $search = db_escape_string($_REQUEST["search"]);
print "
|