|Sending emails to multiple users when a post is commented on|
g emails to multiple users when a post is commented on
| 3:48 pm on May 16, 2013 (gmt 0)|
Ok, I actually write my site in ASP Classic, but ASP isnt a forum and, really, I am looking for generic logic.
I have a site with blog entries. Visitors can comment. I want to add an option for visitors to receive an email when new comments are posted. So, I guess I save the options to a table similar to:
Then, when blogid 20 gets a new comment, I email userids 100, 101, 102.
I am using an ASP email component and with small numbers like this, the logic is simple:
Get records from EmailWhenNewComments where blogid=20
For each record
But with enough records I know this will be very inefficient. When a visitor saves a comment, it will take a long time to send all emails before returning.
What is the correct way to handle this? Does the emailing get de-coupled from the comment saving and run as a seperate process, kicked off by the save? Does the emailing logic just need to be made more efficient with something I am not aware of?
Any input would be greatly appreciated.
|brotherhood of LAN|
| 4:07 pm on May 16, 2013 (gmt 0)|
|But with enough records I know this will be very inefficient. When a visitor saves a comment, it will take a long time to send all emails before returning. |
I assume you are not doing the mailing process as part of the new comment submission logic, i.e. the confirmation page of the newest poster.
Create a mail queue table and run a cron job to deal with the mailing that way.
| 4:25 pm on May 16, 2013 (gmt 0)|
just run it every few minutes? this is a windows server so I dont think there is a cron, but should be something similar. Although it is a shared hosting server too, so not sure if I will have ability to create a timed job. I'll have to check - thanks.
|brotherhood of LAN|
| 4:36 pm on May 16, 2013 (gmt 0)|
I'd just run it every minute, but be sure that emails don't get sent out more than once, i.e. flag them as "being sent".
For Windows, not sure but if there's a control panel with your hosting, have a look at it. Windows does have a cron-type service.
If you hit a limitation of your hosting, then there's not too much you can do about that.
| 8:14 pm on May 16, 2013 (gmt 0)|
also, instead of sending N emails send 1 email and use a bcc: list.
| 8:16 pm on May 16, 2013 (gmt 0)|
I thought I read that a long BCC list is a red flag for spam blockers.
| 11:31 pm on May 16, 2013 (gmt 0)|
Before you do this
- do not send it to anybody who did not do an intentional, confirmed opt-in.
intentional: not forcing, no tricking, no small print, ... and not turned on by default
confirmed: make sure they act upon receiving a first "please confirm" email (it's important the recipient confirms)
opt-in: have them chose to want it.
- always add real world contact info in every email (can be a legal requirement!)
- always add a very easy opt-out: click here, no questions asked, no nothing: you're unsubscribed and will not be bothered again (don't use reply to this email: use a web page)
- make sure the text is factual, not "marketing speak"
That should keep you out of resonable anti-spam lists.
To send it out:
I'd queue them up:
- sort the recipients by domain (the part after the "@")
- then send it in bcc: to about 12 to 20 max recipients in max 3 to 5 different domains per email.
- mark the email as "bulk"
- make sure to have a working email address as sender (even if you do not read it, make sure it's accepted)
- unsubscribe those that come back as undeliverable
Now that -nor anything else you do- isn't going to make you bulletproof against being flagged as a spammer.
If you can: do not send it from a hosting provider IP range. Transfer the work to a fixed IP business connection and send it from there. [they're easier to change IP addresses than they are at hosting providers- and more often than not your neighbors can be pro spammers]
The better alternative:
Or use an API to some outfit that specializes in sending bulk email. I've only ever used mailchimp, but there are others...
| 3:49 am on May 17, 2013 (gmt 0)|
this applies specifically to the USA but has general suggestions that apply elsewhere and echos much of what swa66 suggested.
CAN-SPAM Act: A Compliance Guide for Business | BCP Business Center:
if you follow the bulk email best practices and guidelines suggested by the major email providers you should be in good shape.
Mail Help | - SLN3435 - Best practices for bulk mail senders and postmasters when sending to Yahoo! Mail:
[Microsoft] Policies, Practices, and Guidelines:
Bulk Senders Guidelines - Gmail Help:
| 1:11 am on May 26, 2013 (gmt 0)|
ok, it seems I have another problem. A strange one that I cant seem to find a solution to - or even someone else with the same issue.
To start, on my shared hosting I dont have access to create a scheduled process. So, the only thing I can do is send the email when someone comments on a blog post.
As I was testing this, sending emails to my yahoo account as a test was slow. If I tried to send two or three, it took about 20 seconds total. Even sending just one took 5-10 seconds. That is obviously unacceptable for some to wait that long when posting a comment on a blog. I mulled over some possible work arounds and could find none.
It occurred that I never noticed that kind of delay when I test my registration process. the only difference is that I tested that with my non-yahoo email.
It turns out, sending email from CDO to a yahoo account is VERY slow. Sending to my GoDaddy account or my work email is instantaneous.
I havent tested other account (google, hotmail) but will.
But, any idea why sending to yahoo is slow but sending to other emails is just fine?
| 6:06 pm on May 26, 2013 (gmt 0)|
Graylisting causes email to be intentionally slow.
It's an anti-spam feature that causes delivery of email to be fail on first try and require a retry (MTAs do that). Some spammers don't use real MTAs with queueing, retries and the like and hence their deliveries just fails.
| 12:47 pm on May 27, 2013 (gmt 0)|
hmmm. any way around this?
I dont want to drop a notification feature as it is so important in bringing ppl back to the site.
But if I have even one Yahoo email address to send to, the wait time is as much as 5 seconds for the form to return.
Really the delay is far more important to me.
| 12:57 pm on May 27, 2013 (gmt 0)|
Since your provider doesn't offer cron services. You could ask them if they have somewhere an MTA that's willing to relay for you. That one should accept your message fast and deal with any delay itself. (MTAs are by design store and forward).
BTW: MTA: Mail Transfer Agent. E.g. sendmail