summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2007-08-26 11:32:48 +0100
committerAndrew Dolgov <[email protected]>2007-08-26 11:32:48 +0100
commita89311235c1fab36fda167f69f5f814e84a5f1c6 (patch)
treecd9d38e5c6a65d3398399d7ec2210adc16e640b2
parent2ef1af84c8ee231d421a381a9fceb979fa4c1cb2 (diff)
improve digest sending (closes #138)
-rw-r--r--README2
-rw-r--r--config.php-dist18
-rw-r--r--functions.php43
-rw-r--r--phpmailer/language/phpmailer.lang-en.php23
-rw-r--r--sanity_check.php4
5 files changed, 81 insertions, 9 deletions
diff --git a/README b/README
index e540b90b7..a040066a9 100644
--- a/README
+++ b/README
@@ -12,6 +12,7 @@ Portions (C):
Bob Osola <[email protected]> (pngfix.js)
Sundar Dorai-Raj <[email protected]> (isNumeric() in functions.js)
+ Sean M. Burke. <[email protected]> (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
diff --git a/config.php-dist b/config.php-dist
index ecacf2028..8601f5628 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -73,9 +73,6 @@
define('MAIL_RESET_PASS', true);
// Send mail to user on password reset
- define('MAIL_FROM', 'TT-RSS Daemon <[email protected]>');
- // Pretty obvious, I suppose. Used for email digests & password notifications.
-
define('ENABLE_FEED_BROWSER', true);
// Enable or disable local feed browser
@@ -132,7 +129,7 @@
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);
@@ -177,6 +174,19 @@
// 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', '[email protected]');
+ // 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).
diff --git a/functions.php b/functions.php
index d82cb38ea..e2915aa00 100644
--- a/functions.php
+++ b/functions.php
@@ -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');
@@ -3156,12 +3158,42 @@
$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 {
@@ -3195,6 +3227,7 @@
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
index 000000000..14b677ff1
--- /dev/null
+++ b/phpmailer/language/phpmailer.lang-en.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * PHPMailer language file.
+ * English Version
+ */
+
+$PHPMAILER_LANG = array();
+
+$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
+ 'recipient email address.';
+$PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
+$PHPMAILER_LANG["execute"] = 'Could not execute: ';
+$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
+$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
+$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
+$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
+ 'recipients failed: ';
+$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
+$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
+$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
+$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
+$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
+?>
diff --git a/sanity_check.php b/sanity_check.php
index 33b433d0b..1f5c0210c 100644
--- a/sanity_check.php
+++ b/sanity_check.php
@@ -66,6 +66,10 @@
$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;