tags:

views:

420

answers:

3

I want to send emails through a web app, for example, reminders of a tasks manager, reminders of birthdays... I want to program a date and an hour, and get the email sent at that moment.

I think I have two options to do this: using cron or sending email with a future timestamp.

Using cron involve to run a command (which will query the database) each one, two o five minutes to check if there are any email to be sent. Or, another way, when I save a new reminder, put a new crontab task (via execute a system command from the web app) at the time indicated. With the first option, I think the server load will be excessive. With second option, I'll have hundreds of crontab tasks, what looks dirty for me.

Perhaps I could send the email at the very moment of creating the reminder, but changing the email timestamp to a date and hour in the future. I know some email servers can manage this (like Mercur for Windows), but, is it a standard? I will use my Gmail account to do this job. And, with this solution, I won't be able to cancel a reminder, because the email has been sent at the moment I created the reminder.

I can use PHP or Ruby (RoR) for server language, so the language isn't important, because both of them can send emails and call system commands. If the solution entails scripting, I can use bash scripts, Perl, Python... (the server is a Linux box).

Which do you think is the best method to accomplish the solution to this problem?

I apologize for my poor english. Thanks in advance.

+2  A: 

Having a cron is a better option then sending out emails with future date stamp. Set a cron to run on periodically and it can send out emails.

We have similar questions.

http://stackoverflow.com/questions/1118154/sending-mass-email-using-php

http://stackoverflow.com/questions/215736/how-do-i-send-bulk-mail-to-my-users-in-a-generic-fashion

Read those you will get some ideas.

Shoban
+2  A: 

instead of having a cron job for each reminder (or notification, whatever), you might write everything in a file and periodically (for example every 5 minutes) call a script (e.g. php-script) that reads the file and checks whether to send a notification or not...

you would have the functionality without needing to create a cron-job for every item...

would that be a solution?

regards

Atmocreations
+3  A: 

I don't know if you've looked into this, but since you use GMail I thought you might be interested. Google Calendar has this feature:

  1. Go into GMail.
  2. At the top, click on "Calendar".
  3. On the left is a list of calendars. Each has a small link called "Settings". Follow this link (you may want to create a new calendar for this project).
  4. This brings up a tabbed interface. I think it always brings you to the "Calendars" tab, but if it doesn't, click that tab.
  5. Each of the calendars will have a link next to it called, "Notifications". Click the link for the calendar you want to notify you.

This will bring up a list of settings which you can use to set up notifications by sending an email.

Google's API should allow you to access the calendar to sync it with your application. If it's set to send you an email, it will handle all the email for you.

Imagist
I need to send HTML emails with personalized text, so I think this isn't suitable for me... at the moment. It's a very useful tip, and I'm sure will use it in another project, thanks :)
ARemesal
@ARemesal I suspect that there's a way to personalize the email notifications too, but I wasn't able to find one in a 15-minute search of the internet. Barring that, I would go with Atmocreations' solution (cron + a script to avoid multiple cron jobs).
Imagist