I have developed newsletter module for a single user and its works fine.
Now I need to expand the module for multiple users.
My question is that, how can I manage the newsletters when more than one user schedule newsletters for multiple subscribers at the same time?
I have thought it for 2 ways, First is execute 1st newsletter after it finished send 2nd. Second way is fetch random records for subscribers from database to send the newsletter so it will send it simultaneously.
I would recommend you to store all tasks in the database and function that sends all mails and mark the tasks as done. This function I would execute using a cronjob.
https://ellislab.com/codeigniter/user-guide/general/cli.html
I would also recommend you to send the mails one by one (depending on how many you have to send) to avoid to become marked as spam.
Related
I need to send individual emails to 1500+ subscribers from a WordPress template page. They are not WordPress users but their details are stored in a non WordPress table.
Upon post update, I need to fetch their email addresses from the table and send individual emails to them. The email contains a unique link to unsubscribe.
I have everything working. The only thing is that when the post is updated, it keeps loading and loading as it is sending emails and eventually times out.
Can anyone please advise if there is a better solution to update the post but schedule emails or send emails in chunks of 50s?
As already mentioned in the comments there are some possibilities you can go with - letting WordPress send all those emails on save_post is certainly not a good Idea.
Here are three possible ways you can solve it:
1) Instead of wp_mail() you may want to implement a PHP library for sending many emails fast at once for instance PHPMailer (https://github.com/PHPMailer/PHPMailer).
Advantage: You do not need an external service and no cronjob.
Disadvantage: If the number of subscribers is growing to high this will fail, too.
2) Use an internal cronjob for WP and send chuncks of 50. There are many tutorials out there how WordPress Cronjobs work (https://codex.wordpress.org/Function_Reference/wp_cron)
Advantages: No external service required and almost no limitation in the number of subscribers.
Disadvantages: It will take some time until the WordPress cronjob has finished. It will slow down your site especially if you have many updates.
3) Use an external service like Mailchimp. Just have a look into their API and trigger the email sending.
Advantages: Many additional options. You do not have to implement any sending logic.
Disadvantages: Eventually costs money. Requires Integration of their API. You have to keep subscriber list synchronous.
There are a couple of WordPress plug-ins that do mass mailing. As an example, Mass Email To users. I am going to assume you've looked at them already. I have not used any of them.
What I used to use for an email list of 12,000 subscribers is use PHPList. It has an open source free version which allows you to send 300 messages a month and unlimited subscribers. It allows you to have subscribe/unsubscribe functions with the list and manage your subscribers without adding 1500 accounts to WordPress.
https://www.phplist.com
One of the issues to be aware of is that many ISPs have a 500 message per hour limitation per domain. This means that a list of 1500 people will take at least four hours to send. Why four hours? If you send 500 per hour, you might trip a daemon that blocks your website for using too many resources. Plus you can't receive any emails, since the cap is for every email. But if you dial down your send rate to 400, you should be fine. Even without a restriction, chances are it's going to take a while to send out a message to 1500 subscribers.
I moved onto a email provider like Mailchimp because at 450 emails per hour, it was taking 26+ hours to send an email and mailing list managers tend to be finicky. This gives you all your solutions on one server, which is nice when managing projects.
Good luck.
I have a news portal with everyday news. My need is to send through newsletter the daily news to subscribers.
I've already realized a PHP/MySQL custom newsletter system that performs the following tasks:
fetches the daily news
fetches the list of users who want the newsletter
everynight through a cronjob I launch a script that performs the above every 5 minutes sending the newsletter to 10 recipients at a time each cycle
Problems:
I have to estimate how long this cronjob needs to run in order to complete the full list of users (5' x 10 emails) = 120Email/hours = TotalUsers/emailperhours = number of hours the cronjob needs to run
I overcome this problem because I don't have so much users until now and I can still manage to make the cronjob run enough to send all mails, but for the future?
All email receievers are saved double opt-in, means I'm quite sure of their existence, but it happens how you can imagine that I'll have anyway many Mail delivery for other reasons:
here I need help because I dunno how to catch there Mail delivery through PHP and update MySQL tables in order to suspend these unnnecessary sendings.
Alternatives:
I know that there are many providers who offer Newsletter systems but this works fine every time u go and compile your static email body. Here I need a dynamic email body to be generated every day with fresh news and then send it to recipients.
Still here I need some advice.
You might find it worthwhile using a service like SendGrid - they have an API that handles dynamic content. I haven't tested it out that aspect myself, but for the small price they charge it might be worth saving you the headache.
I run a daily deals aggregator. I'd like to send daily emails to users who sign up for them. The site itself is PHP/MySQL. What should I use to send emails? Each email will be specific to each user depending on the kind of deals that user wants to received. What do sites like Quora or other daily deal sites use to send emails?
I think you can use loops to loop through the emails that are stored in an array where the keys of the array are the respective user ids, and then send emails accordingly. You can use the foreach loop.
You could create a table in your database to temporarily store the addresses that have not yet received a mail and create a cronjob that sends 200 email per 30 minutes or so. Like this you can avoid clicking some button and wait for hours until your script is done.
Remove every address that has received the mail until your table is empty. Use another cronjob that runs every week or month (cycle to send newsletter) that fills the temporary table with your recipient addresses.
HI all,
I have an account in getresponse.com
I want to send emails to the members in my mailing list after one hour of their joining.
Please tell me how can i do this
I don't really know what's that getresponse.com all about and what are your possibilities, but deducing from php tag:
Php scripts can't execute for an hour => you have to schedule this. You need some database(or at least a file or sth else) to store the information when someone joined and a cron script that's scheduled to run eg. every 5 minutes that checks your database and if the time is right sends an e-mail and then removes the entry from database.
Admin interface allows you to create a follow-up message received by subscriber no sooner than 1 day after their subscription, so you will most likely have to send it through their API call:
http://dev.getresponse.com/api-doc/#send_newsletter
I'm creating email notification system on my site to send email to the users who has subscribed the article for new comments... I would like to know what is the best way to handle with this situation in php. Should I use the mail function just after the database insertion or there is some better ways. Will it slow down the process of adding new comments if there are too many subscribers?
I would create a new database table and add the subscribers that needs notifications to that table. Then run a crontab every 5 minutes that sends the emails to those whose article has been commented. That way you don't have to send it directly thus clogging the user experience with longer loading times.
You can send an email as soon as a comment is inserted into the database or when admin/mod approves from admin side if you such mechanism.
Will it slow down the process of
adding new comments if there are too
many subscribers?
It will because you will be sending the email to more and more subscribers. However, you might want to consider optimizing your insertion query as well as your code if you can.