-1

I'm trying to make a site where I can upload a CSV spreadsheet with columns as so:

Email Address | Category | Item | Description | Cost

It would copy the data from the CSV into the SQL database. Now the hard part I can't figure out yet:

I want to run a cron, where any new data under each email address, would be emailed to the email address on file.

I was hoping to use a CMS since I'm still learning, but I can't find a plugin that would allow me to email certain data to specific email addresses if there is new SQL data for that email address (or user's name, I suppose).

Point me in the right direction? Ideas appreciated, too.

  • For sending emails, check libraries like [PHPMailer](https://github.com/PHPMailer/PHPMailer), [SwiftMailer](https://swiftmailer.symfony.com/) – Madhur Bhaiya Sep 19 '18 at 21:21

2 Answers2

1

I would add another integer field to the table called 'email_sent' and on import I would insert 0.

Create a simple php script that will poll this table and look for any rows that have a 0. Retrieve the email address and use something like swiftmailer to send an email. Update the 'email_sent' to be 1 on success.

The second answer here by Alister helped me perform a similar task. How to create cron job using PHP?

Using cron to run a php script fairly straight forward after reading that.

-1

You can upload the file to a temporary table. Then find all the rows in the temporary table that aren't in the permanent table, and send email to those users. Finally, merge the temporary table into the permanent table.

Barmar
  • 741,623
  • 53
  • 500
  • 612