Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Automated Emails dependent on row in database

Explorer ,
Nov 03, 2011 Nov 03, 2011

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

TOPICS
Server side applications
799
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 03, 2011 Nov 03, 2011

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:

http://www.sitepoint.com/introducing-cron/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2011 Nov 03, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 03, 2011 Nov 03, 2011
LATEST

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines