]> git.wh0rd.org Git - tt-rss.git/commitdiff
improve digest sending (closes #138)
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 26 Aug 2007 10:32:48 +0000 (11:32 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 26 Aug 2007 10:32:48 +0000 (11:32 +0100)
README
config.php-dist
functions.php
phpmailer/language/phpmailer.lang-en.php [new file with mode: 0644]
sanity_check.php

diff --git a/README b/README
index e540b90b71f4bd275e95aca5ee9ee158418c7c50..a040066a9323cf1bd1d4ec23466f1eec36073f2d 100644 (file)
--- a/README
+++ b/README
@@ -12,6 +12,7 @@ Portions (C):
 
        Bob Osola <bobosola@gmail.com> (pngfix.js)
        Sundar Dorai-Raj <sdoraira@vt.edu> (isNumeric() in functions.js)
+       Sean M. Burke. <sburke@cpan.org> (xsl_mop-up.js)
 
 Other bundled libraries:
 
@@ -19,6 +20,7 @@ Other bundled libraries:
        Script.aculo.us javascript library, http://http://script.aculo.us/
        MagpieRSS feed parser, http://magpierss.sourceforge.net/
        SimplePie feed parser, http://simplepie.org/
+       PHPMailer class, http://phpmailer.sourceforge.net/
 
 Licensed under GNU GPL version 2
 
index ecacf202879a6b8199d4a922b7cf92426bc3491c..8601f5628eaa728ad1ba7c83de43c2a4e986f36b 100644 (file)
@@ -73,9 +73,6 @@
        define('MAIL_RESET_PASS', true);
        // Send mail to user on password reset
        
-       define('MAIL_FROM', 'TT-RSS Daemon <noreply@some.ttrss.host.dom>');
-       // Pretty obvious, I suppose. Used for email digests & password notifications.
-
        define('ENABLE_FEED_BROWSER', true);
        // Enable or disable local feed browser
 
        define('DIGEST_ENABLE', true);
        // Global option to enable daily digests
 
-       define('DIGEST_HOSTNAME', 'some.ttrss.host.dom');
+       define('DIGEST_HOSTNAME', 'your.domain.dom');
        // Hostname for email digest signature
 
        define('DIGEST_EMAIL_LIMIT', 10);
        // parameter to speed up tt-rss when having a huge number of articles
        // in the database (better yet, enable purging!)
 
+       define('DIGEST_FROM_NAME', 'Tiny Tiny RSS');
+       define('DIGEST_FROM_ADDRESS', 'noreply@your.domain.dom');
+       // Name and address for sending email digests from.
+
+       define('DIGEST_SMTP_HOST', '');
+       // SMTP Host to send digests. When blank tt-rss uses
+       // PHP's default mail() function.
+
+       define('DIGEST_SMTP_LOGIN', '');
+       define('DIGEST_SMTP_PASSWORD', '');
+       // These two options enable SMTP authentication when sending
+       // digests. Require DIGEST_SMTP_HOST.
+
        define('CONFIG_VERSION', 9);
        // Expected config version. Please update this option in config.php
        // if necessary (after migrating all new options from this file).
index d82cb38ea5f14692a074304ef1ec42ee085c9bfe..e2915aa0045f0aeaf7bd8c6e0c46d40b338a0c0a 100644 (file)
@@ -61,6 +61,8 @@
        require_once 'errors.php';
        require_once 'version.php';
 
+       require_once 'phpmailer/class.phpmailer.php';
+
        define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')');
        define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
 
                                $headlines_count = $tuple[1];
 
                                if ($headlines_count > 0) {
-                                       $rc = mail($line["login"] . " <" . $line["email"] . ">",
-                                               "[tt-rss] New headlines for last 24 hours", $digest,
-                                               "From: " . MAIL_FROM . "\n".
-                                               "Content-Type: text/plain; charset=\"utf-8\"\n".
-                                               "Content-Transfer-Encoding: 8bit\n");
+
+                                       if (!DIGEST_SMTP_HOST) {
+
+                                               $rc = mail($line["login"] . " <" . $line["email"] . ">",
+                                                       "[tt-rss] New headlines for last 24 hours", $digest,
+                                                       "From: " . DIGEST_FROM_NAME . " <" . DIGEST_FROM_ADDRESS . ">\n".
+                                                       "Content-Type: text/plain; charset=\"utf-8\"\n".
+                                                       "Content-Transfer-Encoding: 8bit\n");
+
+                                       } else {
+
+                                               $mail = new PHPMailer();
+
+                                               $mail->PluginDir = "phpmailer/";
+                                               $mail->SetLanguage("en", "phpmailer/language/");
+
+                                               $mail->From = DIGEST_FROM_ADDRESS;
+                                               $mail->FromName = DIGEST_FROM_NAME;
+                                               $mail->AddAddress($line["email"], $line["login"]);
+                                               $mail->Host = DIGEST_SMTP_HOST;
+                                               $mail->Mailer = "smtp";
+
+                                               $mail->Username = DIGEST_SMTP_LOGIN;
+                                               $mail->Password = DIGEST_SMTP_PASSWORD;
+
+                                               $mail->Subject = "[tt-rss] New headlines for last 24 hours";
+                                               $mail->Body = $digest;
+
+                                               $rc = $mail->Send();
+
+                                               if (!$rc) print "ERROR: " . $mail->ErrorInfo;
+
+                                       }
+
                                        print "RC=$rc\n";
+
                                        db_query($link, "UPDATE ttrss_users SET last_digest_sent = NOW() 
                                                        WHERE id = " . $line["id"]);
                                } else {
                                ref_id = ttrss_entries.id AND feed_id = ttrss_feeds.id 
                                AND include_in_digest = true
                                AND $interval_query
+                               AND hidden = false
                                AND ttrss_user_entries.owner_uid = $user_id
                                AND unread = true ORDER BY ttrss_feeds.title, date_entered DESC
                        LIMIT $limit");
diff --git a/phpmailer/language/phpmailer.lang-en.php b/phpmailer/language/phpmailer.lang-en.php
new file mode 100644 (file)
index 0000000..14b677f
--- /dev/null
@@ -0,0 +1,23 @@
+<?php\r
+/**\r
+ * PHPMailer language file.  \r
+ * English Version\r
+ */\r
+\r
+$PHPMAILER_LANG = array();\r
+\r
+$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .\r
+                                     'recipient email address.';\r
+$PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';\r
+$PHPMAILER_LANG["execute"] = 'Could not execute: ';\r
+$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';\r
+$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';\r
+$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';\r
+$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .\r
+                                       'recipients failed: ';\r
+$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';\r
+$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';\r
+$PHPMAILER_LANG["file_access"] = 'Could not access file: ';\r
+$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';\r
+$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';\r
+?>\r
index 33b433d0bfa2a260abe8ebb6a64279f9e97990f1..1f5c0210c36f31f4cdc620f16f94d5c953b0842b 100644 (file)
                $err_msg = __("config: DATABASE_BACKED_SESSIONS are currently broken with MySQL");
        }
 
+       if (defined('MAIL_FROM')) {
+               $err_msg = __("config: MAIL_FROM has been split into DIGEST_FROM_NAME and DIGEST_FROM_ADDRESS");
+       }
+
        if ($err_msg) {
                print "<b>".__("Fatal Error")."</b>: $err_msg\n";
                exit;