Firefox PHP

Email All Posts module

Posted by Chris Eaton 
Re: Email All Posts module
March 10, 2005 01:59PM
is there the possibility to get messages with attachments, too? Maybe another hook?

Clemens Weiß
Re: Email All Posts module
March 16, 2005 06:46AM
Hello everyone,
I have installed phorum 5 on our server and am very happy with it. I made many hacks to meet the needs of our "powers to be" around here.

Among my million+ things to do, I have a request if someone can help me...

Here is where i want to be...

I want a copy of ALL posts to go to ALL USERS.

I have tried hacking so that all users default to follow all threads, but the problem is they only get the "new meesage in phorum" email and not the text, they can choose to stop follwing, and according to management; "We don't want the users to have to come back to the phorum just to read the message.
(We work in an industry that alot of people cant/wont drive around alot...they only read emails, and if they want to post/reply, then they can come back to visit us..."

I know that phorum-mail may be coming (soon?), but if someone has the time, i would like to hack the emailallposts MOD so that EVERY user will be emailed a copy of the an actual posted messaged.

I set it up the way it was built and it works great.

So, without totally destroying the original phorum code, i tried the emaillallposts, but with 100-200 users, this is close, but instead of specifying one address in the "settings", i would like an option, or just to change the script(s) to fire off the message to ALL users.

Is this the right place to make the hack (emaillallposts) or is there somewhere else that i didn't think of that wwouuld be easier?

Haa! (i know, thats what i said)
But, if someone has the time to help, i would much appreciate it.


(by the way, i am a coder from the 80's still chuggin' along at it, just looking for a little help/guidance here).
Re: Email All Posts module
March 16, 2005 08:10AM
tbeattie Wrote:
> But, if someone has the time to help, i would much
> appreciate it.

Just a quick & easy solution.

in the module before the mailing part get all emails from user-table and then loop through those?

-=[ Panu ]=-
Re: Email All Posts module
March 16, 2005 08:34AM
Thank you for replying so fast Panu.
That is what i was thinking, i haven't had the time yet to go thru and follow all the VARIABLE names to get it right...

I was hoping someone else had already done this or could write the code faster than i could...

Hopefully i'll find time to "get into" the code a little more, and get it going. Not that i want someone to "do it for me" but that would be greatly appreciated, if it is easy enough...)

I'm glad to know i was heading in the right direction, now i just need to open the wormhole and find a way thru to the other side before management asks "how's it coming"...
(ha ha)

Thanks much again,
Re: Email All Posts module
March 16, 2005 09:25AM
tbeattie Wrote:
> I'm glad to know i was heading in the right
> direction, now i just need to open the wormhole
> and find a way thru to the other side before
> management asks "how's it coming"...
> (ha ha)

I had a look and the place where the recipients are put into $toAddress array is quite clear. So the module takes the mails from it's settings I quess.

replace that with:

$query = "select email from PHORUM_USER_TABLE"
$queryres = mysql_query($query)
while($r = mysql_fetch_row($queryres)
$toAddress[] = $r

or something like that.

Note that sending many emails is time consuming so this is going to slow posting because all the emails are being sent after the post.

I'm not sure if it's a issue or not. You could also use a mailinglist so you could send the message to a mailinglist and on the mailinglist you have all your users. It's a keeping userlist up to date nightmare tho.

-=[ Panu ]=-
Re: Email All Posts module
March 16, 2005 10:24AM
Thank you again...
after reading your response (and feeling reassured that i was thinking about a good approach to this), i got motivated to "dig deeper" so for the last hour i've been driving around in the code and to see where everything is. I started to re-code and then got interrupted (as usual) and then your second response came. GREAT!

I am going to try later tonite (when all the other folks leave me alone) and try it out...

i'm not sure if your code is usable "as-is" or not so i'm going to compare what i started and what you wrote to see if your was proper...

I'll be sure to let you know what i come up with tomorrow...

We don't receive alot of daily activity (posts) so i'm thinking the "delay" will be fine.

I also agree with not using a the maillist approach. I dropped that idea in the beginning because of the maintenance headaches, like you said.

my one concern was the size of the $toAddress when i try to put in 100-200 names. how big will this get? as far as i'm aware, supposebly php has no limit on variable size. (i've heard that before) but i have never tested it out.

I also looked at the phorum_email_notice($message) routine and thought about using the "phorum_db_get_subscribed_users($PHORUM..." routine to get the users???

anyway, i'll kep you informed...
again Thank You much!

Re: Email All Posts module
March 16, 2005 04:45PM
it's me again...
correcting my own message...
(sorry for calling things "routines", i should be calling them "functions")hopefully you knew what i meant.

anyway, insted of "phorum_db_get_subscribed_users($PHORUM..." function i found the "phorum_db_get_search_users($search)" function that returns "user_id","username", and "email"!!! yea!

so i'm gonna start there, if i can't get it going, i'm going to "hack" your code directly into the "emailallposts"...

my only problem with all this that if someone should complain (since we are forcing our emails upon them) i screwed...(no way to stop the train) unless i insert a new row in the user table and check it as a flag?!?!?

I'll figure that out next week/month/year or after the first complaint...

Re: Email All Posts module
March 20, 2005 05:08PM
Hi Everybody,

This is developing into a very interesting thread. I've been asked to put together a system that reflects the facilities found on Yahoo groups: ie a web interface for users wanting a gui tool for the 'archives' with all posts going to the groups of users signed up for immediate receipt or daily digests.

After much hunting around, it seemed the best option was to weld Mailman and Phorum together and configure each to talk to each other.

The solution: this lovely module called "Email All Posts". Now users can email posts and replies to threads to the email address designated for each forum or enter it via the web and each member of that forum will get an email of the post according to their preferences. (I've got some hacking to do for the Mailman user preferences which I hope to create a module for later.)

The only problem has been that you need a different email address for the Mailman mailing list to that of the receiving email address for Phorummail. Till now Email all Posts module hasn't allowed for this.

So I'm very pleased to attach a hacked version Chris's module that now adds a "from address" field in the settings to which replies to email posting will be sent when the user clicks the reply button on their mail client.

The reason I'm so pleased? Well the style of coding for Phorum is very much unlike anything I'm used to,s o to have managed waht eventually turned out to be very simple was rather satisfying - thank heavens for Zend Studio eh?

Compliments to Chris for the original code.

You'll need to alter the phorum_email_user function to:

function phorum_email_user($addresses, $data,$agb_from="")

$mailmessage = $data['mailmessage'];
$mailsubject = $data['mailsubject'];

foreach(array_keys($data) as $key){
$mailmessage = str_replace("%$key%", $data[$key], $mailmessage);
$mailsubject = str_replace("%$key%", $data[$key], $mailsubject);

$num_addresses = count($addresses);
$from_address = "\"".$PHORUM['system_email_from_name']."\" <".$PHORUM['system_email_from_address'].">";
$from_address = "\"".$agb_from."\" <".$agb_from.">";

'addresses' => $addresses,
'from' => $from_address,
'subject' => $mailsubject,
'body' => $mailmessage,
'bcc' => $PHORUM['use_bcc']

$send_messages = phorum_hook("send_mail", $hook_data);

if($send_messages != 0 && $num_addresses > 0){
if(isset($PHORUM['use_bcc']) && $PHORUM['use_bcc'] && $num_addresses > 3){
mail(" ", $mailsubject, $mailmessage, "From: $from_address\nBCC: " . implode(",", $addresses));
} else {
foreach($addresses as $address){
mail($address, $mailsubject, $mailmessage, "From: $from_address");

Let me know if you have any success or failure.

Kind regards


Edited 1 time(s). Last edit at 03/20/2005 05:20PM by veloceraptor.
open | download - (2.6 KB)
Re: Email All Posts module 2 group
February 02, 2007 07:06PM
This module hack includes sending all posts as a notification to a specified user group
open | download - emailallposts2group.tar.bz2 (2.2 KB)
Re: Email All Posts module 2 group
February 03, 2007 07:40AM
isn't that last "module hack" the same as the mod just posted in []

Thomas Seifert
Sorry, only registered users may post in this forum.

Click here to login