Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
410 views
in Plugins by
I am currently developing a plugin that sends out questions from yesterday to users that have tags of those questions favorited.

In a foreach() I am directly calling:

                qa_send_email(array(
                    'fromemail' => qa_opt('mailing_from_email'),
                    'fromname' => qa_opt('mailing_from_name'),
                    'toemail' => $userinfo['email'],
                    'toname' => $userinfo['handle'],
                    'subject' => $mailsubject,
                    'body' => trim($emailbody),
                    'html' => true,
                ));
 

From q2a core mass mailing I have seen that gidgreen implemented kind of mail buffer which sends out emails step by step (bunch of 100 or so).

Questions:

1. Do I have to do the same buffer mailing?

Currently I have only 150 users in the forum. What if I would have 15000?

2. Can I just stick to qa_send_email() without any concerns?

Would be nice if somebody can give advice for me and the others!

Thank you
Kai
Q2A version: 1.6.3
by
Hi Kai,
I can not help you with technical tips, however based on my experience mailchimp would work better for you in the following manner
1- It generates lots of helpful reports as to who opened your email, who opted out etc
2- your domain will not be flagged as spam as the emails cumming from mailchimp
3- you dont have to spend time in working on this issue and can focus on more important issues which are keys to attract more visitors to your website

just a suggestion thought to share with you

1 Answer

+2 votes
by

Check out the Async Email Plugin by sama55 - I believe it's for these sorts of situations. You're best off not sending all the emails synchronously in response to a web page request.

by
I consider adding a sleep(); to the foreach that is sending the emails. This way I have some control over it. Plus it feels kind of asynch if 1000 mails are distributed over 10 - 100 seconds ;)

Only question is how long can the script be executed. Imagine thousands of emails.
by
The script execution time means this is not a good solution. The user's browser will still be showing progress while the emails are going and if they click 'stop' the emails could stop (depends on browser/network/Apache configuration). The right answer is to do it asynchronously I'm afraid.
by
Ah, I did not know that this can happen, i.e. that the browser has the "power" to stop a process on the server. Sounds insecure to me actually.

Anyway, I guess best would be to setup a cronjob to overcome this problem? -- In my case I need to send an individual generated email newsletter one time per day.

The only reason why I would implement sleep() - I was reading somewhere that if you send out 1000 emails at once your mail server is quickly regarded as a spam server. I wanted to avoid this by buffering the mail process.
by
With that amount of messages, Id recommend a real email manager.  My provider starts off with 5,000.  But you need to request to do so.  It can be increased with written permission.  The product is called ListMessenger, about $60 USD.  My provider was GoDaddy at the time.  I never had an issue.  Probably because we set it as one-click opt out, and never emailed someone that did not opt in.  Quite simply, never email someone unless they asked for it - this is how we maintained it.

We had over 150,000 members.
by
You'd be better off running PHP via the command line in this situation, but that's probably not feasible for most people.
...