Hi everyone,

On our university website, we would like to send notifications of posts to users (well, basically, use subscriptions =D), but the e-mail policy of the mail server prevents our server from sending too many e-mails. As a workaround, the university suggested we could use their list server, sympa, and send the subscription mails to one single address at the list server.

Now, here is what I thought of: modifying the mail handling module of subscriptions, I could create something like 10 lists, and rotate through them. Every time a subscription has to be sent out, the mail handling module would create a list with all the recipients and store it in a text file. Then, it would send an e-mail to list1@myuniversity.com. Sympa will then retrieve automatically the text file and do everything that is appropriate. The next subscription would be sent to list2, and so on. The rotating of the lists would be to avoid time conflicts (when two or more subscriptions are posted at the same time), and 10 is enough because not so many users are allowed to send e-mails to mailing lists.

Do you think this is a reasonable approach, or should I do this with another module, or is it maybe already implemented in another module ?

Any help would be greatly appreciated.

Have a nice day,

Felix.

Comments

gustav’s picture

The easier solution would be to get a free gmail account (mail.google.com) and use their mail server to send the emails.

salvis’s picture

the e-mail policy of the mail server prevents our server from sending too many e-mails. As a workaround, the university suggested we could use their list server, sympa, and send the subscription mails to one single address at the list server.

Indeed, this sounds like an incompetent bureaucracy. What exactly are they trying to achieve by putting obstacles in the way of legitimate users and then suggesting kludges to work around their obstacles?

If they are unable to administer their email servers, I wouldn't try to implement such a complex solution that relies on their list server. Maybe you should just run your own SMTP server — it's not that difficult — or follow gustav's suggestion.

I don't understand what you mean with time conflicts. The notifications are only sent when cron runs, in a strictly sequential manner.

skizzo’s picture

Re Gustav comment #1: if I understand it correctly you may have the same problem with Gmail. See I reached a sending limit". Actually I am interested in this issue, as my mail is handled by Google Apps and I was thinking to install Subscriptions. Google mentions a limit of "500 external recipients" per day: those would all be sent from noreply@mydomain.com. So maybe I will have problems starting with message 501... I could try to setup my own smtpd on the same httpd server, but I am not competent in mail administration. Also, I like the idea of having the SMTP server up and running even when the httpd server is down. Is my understanding correct?

salvis’s picture

Category: feature » support
Status: Active » Closed (fixed)

Feel free to reopen this if you want to continue the discussion...

felixsmile’s picture

Status: Closed (fixed) » Active

Hi again!

So sorry I didn't write earlier, I guess I'll have to review my subscription options on drupal.org (I thought I would be notified, but well... =D)

Thank you for all your suggestions, let me explain :

- The mail server of the university only accepts a certain number of e-mail (something like 50 or 100) every 10 minutes or so, but these 10 minutes are not reset unless the sending mail server has been quiet for 10 minutes. I'm not too sure how exactly their spam filter works, but it's something like that. What this means is that using any web server in the world (excepted a whitelisted one), it takes about 2 or 3 days to get some 200 e-mail over =D The rest are rejected (because most of the webservers stop trying after that).
- As we're using public web hosting for the webserver, the university would not whitelist it (which is understandable).
- The problem is to find a mail server that is using sendmail and not qmail, for instance. Why? Because what the mail server of the university allows is one single e-mail with a lot of Bccs. Perfect, you might think, in that case, I just modify the notification and everyone gets the same e-mail. Unfortunately, qmail and some other programs of it's kind take the e-mail with all the Bccs and split it :) As a result, the mail server of the university get's the same amount of e-mails. Sendmail doesn't do this, but virtually no one uses sendmail (google for instance isn't, if my last test was correct).

Basically, to summarise, I will never win a fight against the super high end spam filter of the university if I don't manage to do one of the following :

- send e-mail directly to the mail server putting everyone in BCC... which is not possible, unfortunately, because my web hoster blocks port 25...
- use their list server.

The issue with what salvis called quite correctly "legitimate users" is that in case the webserver gets hacked (yes, yes, you always have to start from the worst case =D), it would not be a legitimate user anymore, and as they can't control our webserver (and don't want to), they have to protect their precious e-mail system against this kind of threats. :)

Now the thing with the "time conflicts". Cron is run every hour (that's enough for notifications). My plan was to "rotate" through the list addresses to send everyone his notification. Now, if I have, let's say, 10 lists, and 11 people are posting, in the same hour, something which needs a notification sent out, then the subscription module would use for the first notification list1, for the second notification list2, for the third list3..., and for the eleventh list1 again. That would mean that the first notification and the eleventh notification would be sent to the same people (the ones that were supposed to get the eleventh).

I don't know if I'm really clear about that, if not, I'll try to explain it again =D

Anyway, supposing there was no way around this =D (or, actually, :( ), do you think modifying the mailer module of subscriptions would be a good place to start? Or should I rather modify another module (like notifications, or some other module...)? I'm asking this also for "future development", i.e. because I'd like to make sure subscriptions will be ported one day to drupal 6, etc.

Supposing I decide to move on with the subscriptions module, where would you store the information about the list subscriptions should use next? In a new entry in the database?

Well then, thank you very much for your ideas and your support, I hope I'll manage to find a good solution for everyone =D

Cheers and have a nice day!

Felix.

salvis’s picture

- The mail server of the university only accepts a certain number of e-mail (something like 50 or 100) every 10 minutes or so, but these 10 minutes are not reset unless the sending mail server has been quiet for 10 minutes.

That seems perfect. If you run cron every 12 minutes, and you limit it to sending 50 messages, you can get 250 messages out per hour. Yes, you can set the maximum number of messages per cron run.

It takes about 2 or 3 days to get some 200 e-mail over

Something's not right here...

Also, multiple comments to one node are always collapsed into one notification, and if you encourage your users to use digest mode, all their pending notifications will be collapsed into one.

Sorry, I don't understand what using 10 lists would give you. 10 lists of what? In what way do the 10 lists differ?

Every time a subscription has to be sent out, the mail handling module would create a list with all the recipients and store it in a text file.

You mean you'd gather the recipients of the notification for node 123 into one list, send that to the listserver to reconfigure its subscriber list, send the notification to the listserver for distribution, gather the recipients of the notification for node 124, reconfigure the listserver again, etc.?

I don't think this can work reliably, because if two emails are sent in rapid succession, there's no guarantee that the first will arrive before the second. You'd have to be able to put the recipient list into the actual message and have the listserver separate the two.

Is your IT infrastructure department in the service business? Why don't you just let them help you...?

I will certainly port Subscriptions to D6 — I need it myself. :-)

felixsmile’s picture

Hi Salvis!

Thanks for your complete and quick answer, I'll try to give you answer to everything =D

That seems perfect. If you run cron every 12 minutes, and you limit it to sending 50 messages, you can get 250 messages out per hour. Yes, you can set the maximum number of messages per cron run.

Oh, cool, that might be an acceptable workaround for the moment (even if that means that not everyone gets the messages at the same time...). Another limit is my provider, that is limiting cronjobs to 1 per hour (but don't worry, webcron.org will be able to help me out =D)

It takes about 2 or 3 days to get some 200 e-mail over

Something's not right here...

You're so right :) That's the problem... Everything that comes from outside the university is suspicious...

You mean you'd gather the recipients of the notification for node 123 into one list, send that to the listserver to reconfigure its subscriber list, send the notification to the listserver for distribution, gather the recipients of the notification for node 124, reconfigure the listserver again, etc.?

Yes, nearly. Actually, except for the step "sending the list to the listserver" because the listserver would actually retrieve that list itself. (sympa can "link" one list to one textfile that it retrieves every time it sends an e-mail).

I don't think this can work reliably, because if two emails are sent in rapid succession, there's no guarantee that the first will arrive before the second. You'd have to be able to put the recipient list into the actual message and have the listserver separate the two.

That's where the ten lists would come into play. To avoid this kind of problem, I wouldn't use the same list every time. The notification for node 123 would be sent, for instance, to list1@listserver.com and the recipients written in list1.txt. The notifications for node 124 would similarly be sent to list2@listserver.com and the recipients written in list2.txt. And after 10 notifications, we start over from list1 again, hoping (knowing, because users can only subscribe to taxonomy terms, and only to some of them) that there won't be ever 10 nodes posted between two crons (in an hour's time).

Is your IT infrastructure department in the service business? Why don't you just let them help you...?

No, you have to understand, our IT department is extremely busy :) It's already a big concession from their side to let me use their list server...

I will certainly port Subscriptions to D6 — I need it myself. :-)

Cool =D

I hope it is clearer now. Maybe the "workaround" solution you mentioned (limiting the number of e-mails sent out - a feature I had overlooked because it was not in the first version of subscriptions I had installed) will be quite helpful in the meantime...

Please tell me what you think of the idea with the lists, or any other idea if you think what I was suggesting is simply too stupid... :)

Cheers, thanks a lot and have a nice evening / day, wherever you are right now,

Felix.

salvis’s picture

Ok, now I finally understand your 10 lists. This means that you can't send out more than 10 different notifications per hour. I don't think that can work. One person reading and replying to 5 topics will already use up 5 of your 10 slots. Once you send out notifications, people may come it in droves right after getting a notification about a hot topic, and your 10 slots will be gone in a few minutes.

What you really need is a custom mail exploder. Can you telnet to port 25 of your university mail server from inside the university net? Using Delphi or C++-Builder and the Indy components, you should be able to write a little app that pops from a mailbox, extracts the list of recipients, and smtps to your mail server.

Somewhere here in the issues queue is a patch that claims to collect notifications and send them by BCC. I haven't really looked at it because I don't think it's a good idea, but it may give you a headstart on the PHP end.

felixsmile’s picture

Hi Salvis,

Thanks for all your help.

The BCC issue you might have been referring to might be this one http://drupal.org/node/182450 and was created (and closed right now) by myself... Now this is not a good solution because of the reason I mentioned above (most of the servers are using something like qmail which splits the message and sends every e-mail separately, thus loosing the advantage of the BCCs, and plus, you actually can't put that many BCCs in one mail). Anyway.

Now, I haven't got a forum installed or anything where you can post comments that will be sent out to everyone, so there won't be any "hot topic" and tons of replies in one hour (at least something positive =D).

The custom mail exploder would be a really nice idea, indeed. But... (always a but...) the university doesn't want me to do that, they prefer their list server. What can I do?

Oh well, I'll try to dig into the code and find out the best way to make a list out of what I get from the subscription_mail module. The problem is the following: in 1.9, the e-mails for a node were processed together, so I could group them easily.

Now, I have no idea how the new module will check the subscriptions... Will I have to create 10 global variables and check every time if $body == $bodyGLOBAL1 ? And at the end, send all the e-mails ? That's not very clear. Basically, each of those global variables would contain one body of a subscription that needs to be sent out between two crons. After processing all the subscriptions (running through the loop), I would have one array of user IDs (and e-mail-addresses) for each "type" of e-mails sent out, and would then send the e-mail and write the list with the user IDs in a text file.

Sound feasible, but not exactly simple. Would you recommend sticking to 1.9 (although it has the known issues with rights management and will probably not be ported to Drupal 6)?

I'll try to post some code as soon as I've come a bit further.

If you have any other idea like the one you posted before (with the custom mail exploder), please tell me, I'm not too much fond of the idea of programming something is not necessarily ideal...

Well then, cheers, thanks a lot again, and have a nice day,

Felix.

salvis’s picture

Right, the BCC issue was yours, sorry... Another reason why I think using BCC is not such a great idea is that BCC is considered spammy, especially large BCC lists (if you manage to get them out).

Merging mails won't be so easy. One thing that will help is if you can limit the available kinds of subscriptions to one.

Do you need to notify about comments? about updates? What's the content type(s)?

If you're willing to bet that there will never be more than one subscription item created at the same time, then all pending queue records for the same item will have consecutive sqid's.

If 1.9 works for you, then feel free to keep using it, but I've suffered too much from it (as a user) to recommend it for anything, and I won't ever touch it again. So, unless you do it, the chances for 1.9 to get ported to D6 are nil.

felixsmile’s picture

Hi Salvis,

Sorry for the long silence.

The content types will be a couple of different ones, but they're all very simple content types (some text, a body, that's about it).

All the subscriptions will be "triggered by taxonomy", i.e. people are only able to subscribe to taxonomy terms (but there again, different terms from different categories...)

If you're willing to bet that there will never be more than one subscription item created at the same time, then all pending queue records for the same item will have consecutive sqid's.

No :) I'm not =D That's a dangerous bet to make...

If 1.9 works for you, then feel free to keep using it, but I've suffered too much from it (as a user) to recommend it for anything, and I won't ever touch it again. So, unless you do it, the chances for 1.9 to get ported to D6 are nil.

I guessed so, and I understand why (although I quite liked it, it did most of what I wanted without "complaining" =D).

Basically, you seem to be saying that the task is nearly impossible, unless I want to recode the whole module :)... If that is so, I'll try to look for some other solution, if you have any good idea, please tell me (for instance another module close to subscriptions that you know might be easier to recode ?) :)

Thanks for your time and effort,

Felix.

salvis’s picture

Basically, you seem to be saying that the task is nearly impossible, unless I want to recode the whole module

No, I'm just trying to get a better picture. Do you need comment and update subscriptions, too? or just notifications for node creation?

felixsmile’s picture

Ah, cool :)

Comments are disabled nearly everywhere, so comment subscription won't be needed. And update subscription might be nice, but is not absolutely necessary.

Thanks for your help!

Felix.

salvis’s picture

In the loop in subscriptions_mail_cron() you have a query that retrieves a row from {subscriptions_queue}, which is subsequently processed.

Right after retrieving that row, you can retrieve all other rows that have the same load_function and load_args. That gives you all notifications for that one node. Collect all recipients, build your distribution list, patch the address of your list server into the original row, delete the additional ones and let subscriptions_mail_cron() run its course.

You have to disable comment subscriptions and digest mode for this to work, and to anonymize the mail template, of course.

This will bypass the access checks that are usually done for each user (and if it fails for the first one, nothing will be sent at all). Depending on whether and what node access modules you use, this can be a problem.

salvis’s picture

Version: 6.x-1.x-dev » 5.x-2.0
Status: Active » Fixed

Feel free to reopen if you want to discuss this further (or to report success :-) ).

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

salvis’s picture

Status: Closed (fixed) » Active
salvis’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.