improve digest sending (closes #138)
This commit is contained in:
parent
2ef1af84c8
commit
a89311235c
2
README
2
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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', '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).
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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: ';
|
||||
?>
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue