I'm trying to write a PHP cron job that would call an API, return a set of numerical variables, calculate a second set of variables, and send an email to selected recipients with those variables plugged into the text.

My question: should I do this in a three-step process:

  1. Call API and log variables in JSON file
  2. Calculate new variables and write to 2nd JSON
  3. Send email referencing 2nd JSON variables

Or, alternatively, can the call, calculation, and email function be executed in a single job? I don't see any documentation on sending emails with dynamic variables based on an API call, so if you know of any documentation on this subject please share!

  • Where is WordPress involved in this? And why don't you just build the email content dynamically before sending? Where is the email content coming from? – czerspalace Aug 27 '15 at 22:40
  • The website that I'm using is on Wordpress and this is going to be a plugin. Building dynamic email content before sending sounds like a great idea. I guess I'd call the API for variables in one job, build the dynamic content in another job, and send in a third job? – priorww1 Aug 27 '15 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.