[BETA] Megamail 0.9.6 (was 'Split MassMail in Chunks 0.9.2')

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

[BETA] Megamail 0.9.6 (was 'Split MassMail in Chunks 0.9.2')

Post by R. U. Serious » Sat Apr 12, 2003 12:21 pm

I only tested it in a debug mode, without actually sending out emails. (There was no reason to, yet). It should be working ok. If you previously had problems sending out emails (to all users) , because you had to many members, and thus you were receiving errors, because of too many recipients, then this MOD hopefully is a solution.

Please give feedback in the form of:
- Does emailing work at all? Cann you mass mail small groups (less than 20 members) ?
- How many users you have or the email was sent to
- The problems you had when you tried to send those emails prior to installing the MOD
- The error message you used to receive prior to installing this MOD
- Does this MOD work for you? Any problem/issues I overlooked?


This was discontinued and replaced with a more sophisticated mod, see below: http://www.phpbb.com/phpBB/viewtopic.ph ... 729#561729


discontinued, replaced with megamail 04. May 03
updated to 0.9.2 25. April 2003
updated to 0.9.1 24. April 2003

Code: Select all

############################################################## 
## MOD Title: Split Mass Mail in Chunks
## MOD Author: R. U. Serious <r.u.serious@handykoelsch.de> www.handykoelsch.de
## MOD Description: This MOD relates to the Admin-Mass-Mail function.
##                  Instead of sending a single email with all recipients as BCC,
##                  it will split the mail up in several emails each with 100 users in 
##                  the BCC-field. This is to work around problems for larger boards
##                  to send mass mail.
## MOD Version: 0.9.2 
## 
## Installation Level: easy
## Installation Time: 6 Minutes 
## Files To Edit: admin_mass_email.php, templates/subSilver/admin/user_email_body.tpl
## Included Files: n/a
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/ 
############################################################## 
## Author Notes:  When using the massmail-feature, It will take quite a while to process.
##		  Do _NOT_ resubmit the form, just wait... ;)
##
##
## Version History: 0.9.2 Fixed Problem that it's only refreshing.
##		    0.9.1 Added Javascript to prevent re-submission of form
##		    0.9.0 Initial version 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ OPEN ]------------------------------------------ 
# 
admin/admin_mass_email.php

# 
#-----[ FIND ]------------------------------------------ 
# 
if ( isset($HTTP_POST_VARS['submit']) )

# 
#-----[ REPLACE ]------------------------------------------ 
# 
if ( isset($HTTP_POST_VARS['message']) || isset($HTTP_POST_VARS['subject']) )

# 
#-----[ FIND ]------------------------------------------ 
# 
		$bcc_list = '';
		do
		{
			$bcc_list .= ( ( $bcc_list != '' ) ? ', ' : '' ) . $row['user_email'];
		}
		while ( $row = $db->sql_fetchrow($result) );


# 
#-----[ REPLACE ]------------------------------------------ 
# 
		$bcc_list = array();$j=0;
		$bcc_list[0] = $row['user_email'];
		for ($i = 1;;$i++)
		{
			if ( !( $row = $db->sql_fetchrow($result)) ) break;
			$bcc_list[$j] .= ( ( $bcc_list[$j] != '' ) ? ', ' : '' ) . $row['user_email'];
			if (($i % 100) == 0 ) $j++;
		}


# 
#-----[ FIND ]------------------------------------------ 
# 
		$emailer = new emailer($board_config['smtp_delivery']);

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
	  for ($i = 0; $i < count($bcc_list);$i++)
	  {

# 
#-----[ FIND ]------------------------------------------ 
# 
		$email_headers .= "Bcc: $bcc_list\n";

# 
#-----[ REPLACE ]------------------------------------------ 
# 
		$email_headers .= "Bcc: $bcc_list[$i]\n";

# 
#-----[ FIND ]------------------------------------------ 
# 
		$emailer->reset();

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	  } 


# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/admin/user_email_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
<h1>{L_EMAIL_TITLE}</h1>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
<SCRIPT LANGUAGE="JavaScript">
<!-- 
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
tempobj.disabled = true;
}
return true;
}
else {
alert("The form has been submitted.  Please do NOT resubmit. ");
return false;
   }
}
//  End -->
</script>

# 
#-----[ FIND ]------------------------------------------ 
# 
<form method="post" action="{S_USER_ACTION}">

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
<form method="post" action="{S_USER_ACTION}" onSubmit="return disableForm(this);">


# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
Last edited by R. U. Serious on Sun May 04, 2003 11:14 am, edited 9 times in total.

FunkyDuck
Registered User
Posts: 260
Joined: Sat Apr 20, 2002 11:24 am
Location: Netherlands
Contact:

Post by FunkyDuck » Sat Apr 12, 2003 5:56 pm

- How many users you have or the email was sent to

1961

- The problems you had when you tried to send those emails prior to installing the MOD

cannot send the mailing. it emediatly says: "email send"

- The error message you used to receive prior to installing this MOD

no error

- Does this MOD work for you? Any problem/issues I overlooked?

NO... exactly the same as before
FunkyDuck

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Sun Apr 13, 2003 8:16 am

I have PMed with FunkyDuck to try and rexolve the issue. When reducing the amounts of email-adresses in the bcc-field further from 200 per email down to 20 per mail. Some activitiy was showing. However he said he was experiencing that the mail got sent multiple times.
However the code works fine in that it puts every address only once in a single email. Further "remote-debugging" was not possible.

I would like to get further opinions/experiences on this. :)

If nothing happens, also try reducing the number of 100 to something lower, right here in the code:

Code: Select all

if (($i % 100) == 0 ) $j++; 
Remember that it will take a lot more time the lower that number is (because the more emails you are sending).
Last edited by R. U. Serious on Wed Apr 23, 2003 6:59 pm, edited 1 time in total.

m@rk
Registered User
Posts: 4
Joined: Mon Mar 10, 2003 9:19 pm

Post by m@rk » Wed Apr 23, 2003 6:42 pm

It appears to work for me on my forum. Except I think everyone recieved the email over 10 times at least.

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Wed Apr 23, 2003 6:58 pm

Hmmm, very strange. I am now trying a few things with a friend who happens to have his own server. With 200 it did not work for him. With 150 it worked but with high load etc. It appeared to be fine with 100 though. This might be server/configuration specific. We will look deeper in this.
When we find news/improvememnts/explanations I'll post. :)

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Thu Apr 24, 2003 11:47 am

The only case of multiply received messages were, when the submit button was hit more than one time.There fore a javascript was added to prevent that. If you have JavaScript disabled to NOT resend the form, ONLY hit the button once. It will take a while... ;)

User avatar
scoobie
Registered User
Posts: 237
Joined: Sun May 12, 2002 6:07 pm

Post by scoobie » Thu Apr 24, 2003 6:26 pm

is there any chance this script could send out to 7000 members?
You can have it all if you like... but you can pay for it the rest of your life.

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Thu Apr 24, 2003 6:47 pm

Don't use it at this time. There seems to be unresolved problems. I'll post when I think its safe.

Antony
Registered User
Posts: 529
Joined: Wed Feb 12, 2003 9:06 am

Post by Antony » Thu Apr 24, 2003 6:56 pm

Why not change the title to develompent on hold?
I've Been Banned!

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Wed Apr 30, 2003 11:20 am

Ok, We tried the MOD yesterday on our site. We had around 800 adresses. Mails were split up in chunks of 100.
(From my debugging messages I gathered the following:) The first 300-400 mails were processed rather quick, then it slowed down quite a bit. All in all it took a few minutes until the script was through and the "messages send" appeared.

The maisl were delivered during the next 12-24h.

Every user-email-adress received a single email (just as it should be). To the board-email-adress there were 8 emails sent, which is logical, because the emails were split up, and every mail has to have a valid to-field = board-email-adress (this is already set this way in the original phpBB script).

All in all: The mod worked fine. Wether it is an improvement over trying to send all emails in a single batch, I do not know. Since I do not have the chance to test this myself, and not enough helpful feedback was provided, I don't think I will change anything from this mod...

User avatar
scoobie
Registered User
Posts: 237
Joined: Sun May 12, 2002 6:07 pm

Post by scoobie » Wed Apr 30, 2003 6:10 pm

the problem is that I don't want to test this MOD with 7000 users and have it

1) crash my server
2) send out to each member multiple times
3) something worse

If other people have used this MOD and have witnessed no obvious problems then please let other ppl know

Also is there any optimum PHP settings to send out to thousands of users? Such as to avoid timeouts on script etc

Again R.U. Serious you have made a great MOD I just hope we have people out there who will find a use for this MOD and who are not as sh*t scared as I am of Beta testing, and are willing to help out.
You can have it all if you like... but you can pay for it the rest of your life.

FunkyDuck
Registered User
Posts: 260
Joined: Sat Apr 20, 2002 11:24 am
Location: Netherlands
Contact:

Post by FunkyDuck » Wed Apr 30, 2003 6:43 pm

so lets set the "200" to "100" first ?
FunkyDuck

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Wed Apr 30, 2003 7:02 pm

scoobie wrote: Also is there any optimum PHP settings to send out to thousands of users? Such as to avoid timeouts on script etc

Again R.U. Serious you have made a great MOD I just hope we have people out there who will find a use for this MOD and who are not as sh*t scared as I am of Beta testing, and are willing to help out.


I know how you feel. I did too. :mrgreen:

7000 ppl is a lot of users. Are you on shared hosting or on a dedicated server? I suggest you talk to your hoster on how many recipient he will handle in the BCC field. It is faster and uses less resources if you use bigger chunks, because there is overhead for each time you call mail().

You should also definteley use http://www.php.net/manual/de/function.s ... -limit.php to set a very high timeout. A friend who is using vB on a dedicated server and has about 10.000 users on the board (although I don't know to how many he sent the mail), said he waited for about 20.min. I have heard of people who waited hours, and I heard other people say, that PHP (the scripting language, not phpBB) simply cannot handle a load of several thousand emails.

If you decide to try it, and you want to see how far the script is, right before $emailer->send(); add this line:

Code: Select all

			echo '<h1>'.($i*100).'-'.(($i+1)*100).'</h1><small>'.$email_headers.'<small>';
			flush();
Obviously you would have to change the 100 to whatever chunksize you use. It will print the emails it is sending to.

Independently of how you finally send the emails: Be prepared to receive a loooot of bounced emails. Although we had email-activation right from the start, I had several dozens of email return. A lot of weeding out... :roll:

@FunkyDuck: Like I said I changed the value to 100. I don't know wether that is a good value to set out. It's probably best to talk with you host, and make it rather bigger, if possible. Also you should send at offpeak ours...

edit: Take a look at this thread http://forums.devshed.com/showthread.php?threadid=50305 over at devshed. It also suggests using
ignore_user_abort();
usleep(250000);
I think I'll write all of this into the mod above.

As far as my research has shown, there is not much more cou can do...

User avatar
scoobie
Registered User
Posts: 237
Joined: Sun May 12, 2002 6:07 pm

Post by scoobie » Fri May 02, 2003 7:18 pm

thanks for that r.u.serious... it is very helpful and I might give it a try

I have a dedicated server and have set timeout to quite high
does the MOD refresh the page after every send so timeout? what i'm saying is the timeout based on the BCC size or the sending of the total emails?

cheers again
You can have it all if you like... but you can pay for it the rest of your life.

R. U. Serious
Registered User
Posts: 830
Joined: Mon Feb 11, 2002 2:07 pm

Post by R. U. Serious » Fri May 02, 2003 7:44 pm

scoobie wrote: I have a dedicated server and have set timeout to quite high does the MOD refresh the page after every send so timeout? what i'm saying is the timeout based on the BCC size or the sending of the total emails?


It's only a single page load. So you would have to set the time out rather high. If you put in the debugging-message you will have some indication of progress... (it doesn't impact the sending at all).

I hope it'll work out okay...

One more thing: If I understand the code correct, than when you are sending out mass mail to all users, phpBB sends out mail to literally _all_ users. Even people who may have registered with a fake address that never activated...

If you only want to send to activated users change the following line:

Code: Select all

	$sql = ( $group_id != -1 ) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE;
to look like this:

Code: Select all

	$sql = ( $group_id != -1 ) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE . " WHERE user_active = 1";
Probably will save you a few bounced emails. ;) If you are sending to a usergroup, this will have no effect.

Locked

Return to “[2.0.x] MODs in Development”

Who is online

Users browsing this forum: No registered users and 20 guests