I'm having some problem with a script that send bulk email through PHPmailer class because i exced email per hour limit of my hosting.
I didn't find any option to schedule email, could it be possible to set a delay or time when the email should be send?
Which is the best way, or work around, to send email on scheduled time?
Download a solution specially for newsletters and stuff , in PHP , the most common one is called PHPList , this solution have alot of options that will do schedule and the timeout time automatically for you .
Related
I am working on an email system , All things go fine , I can send email without any error, I have more than 3000 email address and I want to send email to them , but when I press on send button the operation took more than one hour , so I decided to use pear queue mail package, the package now insert the emails queue inside database, but how can I run send function after inserting it in database in background so user will not get confused from a long time that he had to wait .
using loop is a long process to send email one by one it is better to send bulk email. SwiftMailer is best to do that.
use SwiftMailer, which has HTML support, support for different mime types and SMTP authentication (there are very low chances that your email will go into spam).
also, I would like to tell you when you run a long process in PHP it gets time out after some time. you have to increase the execution time in php.ini file.
if you want to stuck with your process(loop).
I am not quite sure how to put my question into words, but this is what I am trying to build. I want to send email using PHPMailer through my gmail account. Now, Gmail has a limit of 500 emails in one day. Another thing to consider is, when you send a bulk email at once, there is a chance that my email is sent back to me, as my bulk email is considered to be a spam. I have around 200 in my contact list. So a limit of 500 is not a problem. Now my question is, is there any native PHP function that will only execute the send function of PHPMailer in a certain amount of time duration? What I want to do is, I want to send 10 emails from my contact list every 30mins.. So if I have 200 in my contact list, there is an interval of 30 mins in every 10 contacts until I send the email to everyone. I have no problems creating the email script using PHPMailer. I just need to know if there is a way in PHP to 'time' the execution of my functions. I would appreciate any kinds of help. Thank you!
I think you should really look for third party solutions. Sending bulk emails via Gmail or any other provider will create problems for you.
I am using MailGun (with 200 mails you can use FREE version) for years and it does the job.
Don't forget to check mailgun for PHP.
I'm a beginner in php and I want to know if there is a way to send out an email with delay. I want to build a website where users can send an email to themselves with their goals and predictions, and after one year, they should receive their own email automatically.
Does anyone has an idea how I could do this?
You will have to take a look at CRON Jobs. CRON Jobs can be set to run at certain intervals. Hourly, Daily ect.
Here is a link to a tutorial.
You would need to store the email inside of a database or something.
Then you would need code that either auto starts 15 minutes after a new row has been added, or you would need code to check through the database for any unsent mail every few minutes. Usually "cron" is used for this.
Is there any way i can send out about 3000+ emails from one php script request without overloading a dedicated IP... the max would be 500 per hour?
If you dont get me.. here is detailed :)
I can only send out 500 emails via the mail() function in PHP per hour via my dedicated IP, is there any way i could send out for example 3000 rows of emails pulled from an email address but stagger the mail() functions out for 500 per hour...
Thanks already!
Create 2 tables, one for the email message and one for the list of recipients.
Then create a script to be run by cron that checks if there is a new message in the message table and if so sends a batch of email to the next set of recipients. Marking each recipient after the mail is sent.
Then you create a web interface for your client to create a message and attach recipients to the message once the user marks the message as ready to go your cron job picks it up and processes it.
If there aren't any messages to be sent your cron job doesn't do anything.
You could sleep between the calls, or, if they're already in a database, put a field in there that says when they were sent. Then you select the ones that haven't been sent, and start from there.
I would put a field in the DB to show when the last email was sent to each user and what email it was. I would also have another DB table to show each email you sent and if it has been sent to all users yet.
User Table:
Id, UserName, Email, etc, DateTimeOfLastEmail, LastEmailId
Email Table:
Id, EmailSubject, EmailContent, DateTimeSent, SentToAll(True/False), DateTimeOfFinish
Thanks for all the answers!
The best way i found was actually to simply sleep() between calls using the sleep() as i tested 400 mails, this took 17 seconds :)
It is unlikely the user will send more than the 450 limit ... but if they do i have an if statement before the while() ends checking if there are more than 450 rows, if so it will sleep between each... this works without fiddly databases :)
Thanks!
well after doing some math you could send an email every 8.3 seconds (498/hr) but it doesn't solve the problem. I think another approach would be to use a DB, query for the 500 and have a CRON job run the script every hour.
So in the DB table you could have the script update a field after the email has been sent so the next cron job will query and get the next 500 emails that need to be sent.
i have a program which use to send group emails, i set a cornjob per mins for this program, and set execute per 2nd/min, and check if the now time is match to my defined schedule time in db. if true the program will run and send email, else nth...
the problem is i want to dynamic set the amount of email sending per mins by user, let say i have 10000 emails to send, and i want to send 3 emails per min, something like that, but i cant find the way when using cronJob, (set cookie? record the current email to db?),
since i found that if i use sleep(), it will cause php execute limit error...
Can anyone tell me how to do that?
or using other method to do schedule task? pear?
if using other methods, can show how to use it briefly ?
Please And Thx
First of all. 10000 emails with 3 per minute will take over 2 days.
Secondly, the best way to do this is to save the emails to database (to, title, body etc) and then create a script that sends out 3 emails and set the cronjob to run every minute.
Also check out these questions.
Sending bulk email in PHP
Sending mass email using php
Best way to send 10,000+ emails with PEAR/Mail_Queue
I think you should set this configuration at the application level rather than the cron job level.
Let's say, cron job should run every minute but the application itself should know howmany e-mails to send when a cron job runs by checking the datetime for the last e-mail is sent, and let's say, send 3 more e-mails and so.
its only example to said 3 emails per mins
actually i want to give user to set the amount of sending email per min/ per hour/ per second
and i know about the send email program, but what if mutil task doing..
such as 3 newsletter will blast at 20/3/2009 15:15:00; each of those target to 10000pls
i dun want to save the whole blast list in db, since client may import a email list for 40000 ppls, always timeout when import, even i set the time limit to 2 mins, dun want to take more then that time
so do u have any sugeestion on the email sending?