26

Re: [Release] AP_Broadcast_Email 1.0

With now 4507 members ... it was impossible to use this plug in which crashes ...

Is it possible to "rewrite" it ?

Re: [Release] AP_Broadcast_Email 1.0

Can anyone help me?

__________________
Fitria Rich - Let's Talk

Re: [Release] AP_Broadcast_Email 1.0

http://punbb.org/forums/viewtopic.php?pid=74951#p74951
If you're getting a 501 error, read that post, apply the fix, see if it works

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

29

Re: [Release] AP_Broadcast_Email 1.0

Rod wrote:

With now 4507 members ... it was impossible to use this plug in which crashes ...

Is it possible to "rewrite" it ?

Seems I am having the same problem too now. Need something that would "limit" the number of emails sent out by the AP_Broadcast_Email to a batch of say 500 emails at a time in different time intervals. Or something like that? ...I dunno.

Re: [Release] AP_Broadcast_Email 1.0

trel1023, it seems to me, that it's too prodigally to generate $mail_subject & $mail_message in loop.

find:

    foreach ($addresses as $recipientname => $recipientemail)
    {
    
        $mail_to        = $recipientname." <".$recipientemail.">";
        $mail_subject   = pun_htmlspecialchars($_POST['message_subject']);
        $mail_message   = pun_htmlspecialchars($_POST['message_body']);

        pun_mail($mail_to, $mail_subject, $mail_message);

    }

replace with:

    $mail_subject   = pun_htmlspecialchars($_POST['message_subject']);
    $mail_message   = pun_htmlspecialchars($_POST['message_body']);

    foreach ($addresses as $recipientname => $recipientemail)
    {
    
        $mail_to        = $recipientname." <".$recipientemail.">";

        pun_mail($mail_to, $mail_subject, $mail_message);
    }

Finally, we can increase maximum execution time
find:

    require_once PUN_ROOT.'include/email.php';

replace with:

    require_once PUN_ROOT.'include/email.php';
    @set_time_limit(0);

31

Re: [Release] AP_Broadcast_Email 1.0

I seem to be on a roll with useless nuggets of info today. big_smile This is an alteration for line 55 in the broadcast mail plugin, again for a pgsql database. Change line ~55 to:

$sql = "SELECT count (username) AS usercount FROM ".$db->prefix."users WHERE username != 'Guest'";

32

Re: [Release] AP_Broadcast_Email 1.0

Wanted to ask:
I want to sent a letter, but I do not want to sent it to banned (or temporaly banned) users.

How can I send to everyone except few (whose emails I would take out from list)?

Re: [Release] AP_Broadcast_Email 1.0

Ahmed wrote:

Wanted to ask:
I want to sent a letter, but I do not want to sent it to banned (or temporaly banned) users.

How can I send to everyone except few (whose emails I would take out from list)?

Change the registered email address of all your banned members to something fictional tongue That's what I've been doing.

Whenever I ban someone I change there email to banned_1@mydomain.com, banned_2@mydomain.com etc, I also change there password so they cant request a new one if the Ban Process ever fails me smile

34

Re: [Release] AP_Broadcast_Email 1.0

downliner wrote:
Ahmed wrote:

Wanted to ask:
I want to sent a letter, but I do not want to sent it to banned (or temporaly banned) users.

How can I send to everyone except few (whose emails I would take out from list)?

Change the registered email address of all your banned members to something fictional tongue That's what I've been doing.

Whenever I ban someone I change there email to banned_1@mydomain.com, banned_2@mydomain.com etc, I also change there password so they cant request a new one if the Ban Process ever fails me smile

I did it this way.

35 (edited by MattF 2008-03-28 11:23)

Re: [Release] AP_Broadcast_Email 1.0

Change this:

else if (isset($_POST['send_message']))
{

        require_once PUN_ROOT.'include/email.php';

        // Display the admin navigation menu
        generate_admin_menu($plugin);

        $sql = "SELECT username, email
                                FROM ".$db->prefix."users
                                WHERE username != 'Guest'
                                ORDER BY username";

to this:

else if (isset($_POST['send_message']))
{

        require_once PUN_ROOT.'include/email.php';

        // Display the admin navigation menu
        generate_admin_menu($plugin);

//--------------------------------------------------------------------//

        $banned_array = array();
        $idcheck = $db->query('SELECT username FROM '.$db->prefix.'bans') or error('Unable to fetch banned users', __FILE__, __LINE__, $db->error());

        while (false !== ($banned = $db->fetch_assoc($idcheck)))
        {
                $banned_array[] = '\''.$db->escape($banned['username']).'\'';
        }

        $banned_array[] = '\'Guest\'';

//--------------------------------------------------------------------//

        $sql = "SELECT username, email
                        FROM ".$db->prefix."users
                        WHERE username NOT IN (".implode(', ', $banned_array).")
                        ORDER BY username";

36

Re: [Release] AP_Broadcast_Email 1.0

Stumbled upon this fine plugin and succeeded in working around the error 501 message by using Smarty's advice earlier in this thread. The patch to avoid banned users only left a blank page but not a single mail was sent.

After running for a while the plugin stopped with another error message:

Error: Unable to send e-mail. Please contact the forum administrator with the following error message reported by the SMTP server: "450 4.1.1 : Recipient address rejected: User unknown in local recipient table ".

I'm running a forum with >2,200 users. Now I don't know how many users have recieved the mail (or how many didn't). Isn't there a way to ignore such things like the 450 error and only report these after completion?

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

37

Re: [Release] AP_Broadcast_Email 1.0

wobo wrote:

The patch to avoid banned users only left a blank page but not a single mail was sent.

It should have worked fine if you applied the changes correctly.

38 (edited by wobo 2008-03-28 02:36)

Re: [Release] AP_Broadcast_Email 1.0

MattF wrote:
wobo wrote:

The patch to avoid banned users only left a blank page but not a single mail was sent.

It should have worked fine if you applied the changes correctly.

Yes, you should say such a thing smile
I inserted the code block by copy&paste, so there's no chance for a typo. But that's no problem as we have only 3 banned users (over more than 4 years!), I will not shed a tear if they got that mail...

The real showstopper is that error I described.

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

39

Re: [Release] AP_Broadcast_Email 1.0

Any chance you could post a copy of the code as it was when you modified that code? I'm curious now. big_smile

Plus, for the failure bit, changing this line:

pun_mail($mail_to, $mail_subject, $mail_message);

to

@pun_mail($mail_to, $mail_subject, $mail_message);

should, I believe, cause it to ignore/suppress the errors and continue.

40 (edited by MattF 2008-03-28 03:06)

Re: [Release] AP_Broadcast_Email 1.0

Apologies. I had cocked up that code above. big_smile (I've edited it so it's now correct).

41

Re: [Release] AP_Broadcast_Email 1.0

MattF wrote:

Any chance you could post a copy of the code as it was when you modified that code? I'm curious now. big_smile

smile Ok, here it is:

else if (isset($_POST['send_message']))
{

        require_once PUN_ROOT.'include/email.php';
        @set_time_limit(0);

        // Display the admin navigation menu
        generate_admin_menu($plugin);
// added by MattF--------------------------------------------------- //
        $banned_array = array();
        $idcheck = $db->query('SELECT username FROM punbb_bans') or error('Unable to fetch banned users', __FILE__, __LINE__, $db->error());

        while (false !== ($banned = $db->fetch_assoc($idcheck)))
                {
                    $banned_array[] = '\''.$db->escape($banned['username']).'\'';
                }

        $banned_array[] = '\'Guest\'';
        // ------------------------------------------------------------------- //

        $sql = "SELECT username, email
                                FROM ".$db->prefix."users
                                WHERE username NOT IN (".implode(', ', $banned_array).")
                                ORDER BY username";
        $result = $db->query($sql) or error('Could not get users from the database', __FILE__, __LINE__, $db->error());
        while($row = $db->fetch_assoc($result))

The problem with the banned users was the database prefix, we use only 'pun_'. While everywhere the prefix is called by its variable ($db->prefix) you named it 'punbb_' in your line starting with '$idcheck.....'. Although, I wonder why I did not get any error message (Unable to fetch banned users)?

pun_mail($mail_to, $mail_subject, $mail_message);

to

@pun_mail($mail_to, $mail_subject, $mail_message);

should, I believe, cause it to ignore/suppress the errors and continue.

Thx, I'll try this.

EDIT: Unfortunately the main problem is not solved by the '@' in front of the function name.

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

42 (edited by MattF 2008-03-28 11:31)

Re: [Release] AP_Broadcast_Email 1.0

wobo wrote:

The problem with the banned users was the database prefix, we use only 'pun_'. While everywhere the prefix is called by its variable ($db->prefix) you named it 'punbb_' in your line starting with '$idcheck.....'. Although, I wonder why I did not get any error message (Unable to fetch banned users)?

I'd not noticed the hard coded prefix. Thanks for pointing it out. smile I've updated the original code again accordingly. smile Is it working okay now, that code?

Btw, not sure on the other failure, offhand. I'll have a peek when I've chance.

43

Re: [Release] AP_Broadcast_Email 1.0

MattF wrote:

Is it working okay now, that code?

I guess so because after fixing that prefix there was no error related to the banned user patch.

The problem with the whole thing is, there is no way to test such a thing as mass mailings. I already received mails from people who complained that they received the mail twice. sad

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

44

Re: [Release] AP_Broadcast_Email 1.0

wobo wrote:

I guess so because after fixing that prefix there was no error related to the banned user patch.

Good to hear. smile


wobo wrote:

The problem with the whole thing is, there is no way to test such a thing as mass mailings. I already received mails from people who complained that they received the mail twice. sad

wobo

Create a test group, add a few test accounts to it and modify the db query in the plugin to only pull that and the banned groups info. Then you'll easily be able to tell that it is both doing the ban list bit correctly, and that it is indeed sending the e-mails correctly. smile

45

Re: [Release] AP_Broadcast_Email 1.0

MattF wrote:

Create a test group, add a few test accounts to it and modify the db query in the plugin to only pull that and the banned groups info. Then you'll easily be able to tell that it is both doing the ban list bit correctly, and that it is indeed sending the e-mails correctly. smile

In principle you are right, but in this case here such a test would not show me such an error as I get with the plugin because I don't know what causes this error. The problem is that there is no info at all how many mails were sent until the error occurred or which address caused the error.

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

46

Re: [Release] AP_Broadcast_Email 1.0

You need to have a delve in: include/email.php. That's the file responsible for the mail functions. You should be able to modify it to bypass a 450 error. If I remember correctly, a 4** code shouldn't be treated as terminal failure anyhow. It signifies a soft failure, not a permanent one.

47

Re: [Release] AP_Broadcast_Email 1.0

MattF wrote:

You need to have a delve in: include/email.php. That's the file responsible for the mail functions. You should be able to modify it to bypass a 450 error.

Sorry, but I disagree. Why should /include/email.php bypass any errors? If a mail gets sent via /include/email.php (like during the registration process or by a topic subscription) I definitely want to know when there is an error with an address, so I can ask the user to fix his profile's mail info.

Broadcast_Email plugin is rather a loop construct where I don't want to end the loop whenever an error occurs. So this loop construct should contain the error handling like, in simple words :

if return(pun_mail) = 1 then
  print "error with user_id [ID number]"
  go on


Sorry, I'm not a coder but you may get what I mean.

Broadcast_Email is a fine plugin, I was desperately searching for a forum mass mail routine. But it is useless for me if only one mail address in a large database is faulty.

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

48 (edited by MattF 2008-03-29 11:46)

Re: [Release] AP_Broadcast_Email 1.0

wobo wrote:

Sorry, but I disagree. Why should /include/email.php bypass any errors?

That's not disagreeing. I just made a poor word choice. smile To rephrase somewhat. As you mention, it should continue looping. That is what I was meaning when I used the term bypass. To report the error is easy enough. It can easily be added to an anrray and reported after completion. For example, this is the mail looping I used in the email_topic form:

        foreach ($rclist as $recipient)
        {
                $recipient = trim($recipient);

                if (is_valid_email($recipient))
                {
                        $rcptlist[] = $recipient;
                        $recipient = $recipient.' <'.$recipient.'>';

                        if ($pun_config['o_smtp_host'] != '')
                        {
                                smtp_mail($recipient, $subject, $message, $headers);
                        }
                        else
                        {
                                mail($recipient, $subject, $message, $headers);
                        }
                }
                else
                {
                        $failedlist[] = $recipient;
                }
        }

with the recipient failure notice:

                if (isset($failedlist) && $failedlist != null)
                {
                        echo "\t\t\t".'<p>'.$lang['email']['Failed recipients'].' '.pun_htmlspecialchars(implode(', ', $failedlist)).'</p>'."\n";
                }

That type of code, added to the e-mail broadcast plugin inplace of the existing, would most likely, (with a bit of tweaking to explicitly catch the smtp errors too), do the job.

49

Re: [Release] AP_Broadcast_Email 1.0

Yes, I think so, although my knowledge is not good enough (by far) to actually tweak the broadcast code,
Like, because I learned Latin in school I understand most Italian documents but I would not be able to write one myself. sad

wobo

FSFE Fellow #359 - The Freedom of Knowledge is a Human Right

50

Re: [Release] AP_Broadcast_Email 1.0

I'll have a look at doing it if I get a chance. smile