Blog Summary Email?

Register an Account
Pligg Chat Room
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2008, 09:17 PM
keg01's Avatar
Pligg Donor
Pligg Version: 1.0.0
Pligg Template: exp realnews
Donation Level 2 
 
Join Date: Oct 2007
Location: Atl
Posts: 73
I have been kicking around the forums for a few days hoping to dig up a thread for what seems to be an obvious feature for a Pligg mod ... does anyone have a working email module that can send a summary of recent posted/published links to registered members (at their preference, of course)?

If not, I'll hack a script together but I don't have the skill to make it a Pligg module so it wouldn't be leveragable by the community.
Reply With Quote
  #2 (permalink)  
Old 07-21-2008, 05:46 PM
keg01's Avatar
Pligg Donor
Pligg Version: 1.0.0
Pligg Template: exp realnews
 
Join Date: Oct 2007
Location: Atl
Posts: 73
This definitely falls into the category of a 'hack' - so take it with a grain of salt. I thought others my benefit from the approach as a temporary solution.

I was so eager for this feature I couldn't wait any longer for a qualified person to contribute it and hacked together my own solution. Like the Little Drummer Boy, it ain't much but this is what I have to give ...

The only customization required of pligg is to the user table to store the user preference for summary emails. The rest is run by crontab, stand alone scripts, all depending on a 3rd party newsletter class (with its own db table for mail queuing). I implemented the excellent class by gabi solomon of:

GS Design Blog

My approach is in no way compiled into a module for Pligg but is just one pligger's way of getting the job done. I am running 9.8.2. For those foolish enough to try this in their own site, be warned that this is not a step-by-step guide but simply an outline of the approach. It has worked very nicely for me for a while now. The key question I've never investigated is capacity - how many messages can your server manage in what time intervals - that is up to each of us to manage. I have implemented this only in a test site myself.

You should be comfortable with crontab, php, mysql, and pligg to try this yourself. You should definitely only try this out in a test environment, not production! - no warranties! Remember, I'm not a developer so think twice about using my code or breaking your pligg site and expecting me to fix it.

With that heavy dose of caution out of the way, hopefully posting this will inspire someone with talent to package this type of feature in a module or in a future pligg release.

Here you go:

1. Add a varchar field to pligg_users, 'user_subscription.' Yes, this is a bad design - should have a separate table of custom user attributes joined but there it is. My script is hardcoded to evaluate only these values for pligg_users.user_subscription: NULL, 'Test', 'Daily', 'Weekly', 'Monthly' - edit the script mailDailyHeadlines.php to suit your own needs.

2. Add a drop-down to the pligg user profile to accept and store the user preference for subscription (I used: 'None' , 'Daily', 'Weekly', 'Monthly'). If you aren't confident in how to edit this profile form, you should not attempt my approach anyway.

3. Download and install the newsletter class in a 3rdparty folder of your making - password protect this directory to keep everyone except your crontab from running scripts!:

Class: Newsletter Queue (newsletter) - PHP Classes

NOTE: This class depends on the presence of 2 additional classes. Both are available from the phpclasses entry above.

PHPMailer-Required, used to send e-mails
MySQL-Required, conect to mysql DB

4. Post my 2 scripts in the 3rdparty folder used for newsletter in #1.
a. The scrappy, ugly but effective message generator (search the php file for occurrences of '***' and update to suit your environment):

mailDailyHeadlines.php (attached below)

and ...
b. The script that actually sends the messages in queue
PHP Code:
<?php
$moduleRoot
=dirname(__FILE__);
require(
$moduleRoot.'/class.phpmailer.php');
require(
$moduleRoot.'/class.newsletter.php');
require(
$moduleRoot.'/easy-mysql-class.php');

$mysql= new mysql('localhost' '***db user''***db pwd''***db' );
$mysql->connect();

$newsletter= new newsletter();
$newsletter->addMysqlObg($mysql);

$sendAttempt=$newsletter->Sendmail();
if (
$sendAttempt===false) echo $newsletter->errorMsg;
else {
    echo 
$newsletter->emailSent.' mail sent.';
}

?>
5. Setup cron jobs to generate messages on a schedule and to send queued messages. Update these examples with the correct web path and password you setup earlier. I run the following schedule:
Code:
//run the message queue every 5 minutes mon-fri
*/5 * * * 1-5 lynx -auth=username:password -dump http://www.yourdomain.com/3rdparty/yourdirectory/queue.php > /dev/null

//generate monthly messages on the 28th of the month at 9pm
0 21 28 * * lynx -auth=username:password -dump http://www.yourdomain.com/3rdparty/yourdirectory/mailDailyHeadlines.php?selectedperiod=Monthly > /dev/null

//generate weekly messages each thursday at 3pm
0 15 * * 4 lynx -auth=username:password -dump http://www.yourdomain.com/3rdparty/yourdirectory/mailDailyHeadlines.php?selectedperiod=Weekly > /dev/null

//generate daily messages each mon-fri at 11:05
05 11 * * 1-5 lynx -auth=username:password -dump http://www.yourdomain.com/3rdparty/yourdirectory/mailDailyHeadlines.php?selectedperiod=Daily > /dev/null
I think that cover it. As I have warned, this is the work of a non-pro. Pray to your favorite deity or just cross your fingers!
Attached Files
File Type: php mailDailyHeadlines.php (6.4 KB, 89 views)
Reply With Quote
  #3 (permalink)  
Old 08-05-2009, 06:47 AM
New Pligger
Pligg Version: 1.0.0
 
Join Date: Aug 2009
Posts: 2
Interesting! So since so far, somebody has realized a newsletter module ?
If not, I will work on it.. But I imagine somebody has already realized right ?!!
In exchange I can work on another module..!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set the email module to send welcome email from my email maiti Questions and Comments 1 02-26-2008 09:25 AM
New EVB experiment cameron65 Questions and Comments 11 12-01-2007 04:18 PM
Sending 'Your product was reviewed' email aaronpais Questions and Comments 1 05-28-2007 08:01 PM
Simple Email Mod - Users Only kahunabear Questions and Comments 4 02-06-2007 08:37 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development