Copy link to clipboard
Copied
Hi all,
I know how to send an email on page load.
But I am looking to send renewal reminders to clients in the background when the website is not in use. So, in my database there will be a renewal reminder date and if it matches with the current date then an email is sent out.
Is this possible with PHP or is it more to do with the server.
I don't want anyone to have to interact with the php page in order for it to send.
Hope this makes sense.
Tom
Copy link to clipboard
Copied
2 ways to go about doing this.
The first, which I would recommend, is tying it into an ESP. Utilize data through and API and use their automated tools to worry about the bulk email task.
Otherwise, what you need to do is set up a cron job on your server to run a PHP script file at a pre-determined time based on pre-determined conditions. Basically by this I would mean that you might want to consider doing the database pull and mailing and 2 different jobs depending on the complexity of the query and the amount of data being queried. Then the second cron job will do the mailing and pull the (ideally) csv file with the mailing addresses, compile the email and then send. Below is a tutorial about cron jobs, and ironically enough about an email script:
Copy link to clipboard
Copied
OK, I think I get the second idea. It'll take abit of getting my head around but that should be fine.
I'm not sure what you're getting at with the first? Any chance of expanding a little?
Cheers
Copy link to clipboard
Copied
Sure. Basically sending emails from your own domain and hosting can be dangerous because let's say you are on a shared server and the guy next to you sends spam, your emails don't get through because they get associated with the server they are sent from. The Email Service Providers (ESPs) like Mailchimp, Constant Contact, Campaign Monitor, etc. all handle this for you and watch spam rates of you and the others around you to ensure higher deliverability rates then what you get. Basically if you tie your data into theirs using an API it takes the sending part out of your equation. You would still need to run the cron on the database query from your end to JOIN your table on the email address with theirs to trigger the send, but it would save your server on resources to not have to worry about bulk mailing all the time to ensure that your site is always running at the highest speeds possible.
It all depends on the size of your task and the strength of the server to be honest. Without knowing your situation I typically assume shared environments where resources are limited. But if you have a server with enough resources or you don't mind the risk of sending from your server then by all means schedule the second cron.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more