I am making a feature on my website that allows the user to enter a task they need to finish by a certain date. The website will then notify them by email when it gets near the date, defined by the user (1 day before due date, 2 hours before due date and so on..) I am totally new to notifications and am unsure how to ask this question but here it is in an example of what I want done...
In an example:
The user types in "Need to call boss."
The user enters in the date selector, May 31st at 11:00 AM.
And then clicks the "Notify me 1 day before"
They enter their email and click submit.
My website will then notify them by email on May 30th at 11:00 AM reminding them to call their boss...
I have looked around and have noticed somethings pointing to CRON jobs.. I looked at that and am unsure if that is the way to go...
Thanks for the time!
It depends on your server. What OS, what access you have and a bunch of other stuff.
On Linux, a cron job would work. On Windows server, Task Scheduler would do the same job. Basically, you need a mechanism to call a script that will read through your database and send emails depending on conditions being true.
Related
I am stuck with algorithm to mail notifications for users. Website is built on PHP 5.4 and MySQL 5.5 .
I have simple one-to-one messaging system built on the site I am working on, and these messages are stored in a database. The task is to send daily email at 9:00am with notification if user has some unread messages waiting for him.
The way how I accomplished it by now is this:
I run the script with cron (every 10 minutes) to collect rows after the last ID of checked message (ID is stored in 'notifications_work_table') from 'messages_table';
according to collected data, I count how many unread messages has each user on that database and then I make personalised message for each user, and store that message in 'mailing_queue_table' and setting the time to send this message at tomorrows 9:00am (if its past 9:00am this day), or to todays 9:00am (if it's past midnight this day). On 'notifications_work_table' ID is updated to last checked message id;
in parallel I run another script with cron (also every 10 minutes) to check if there are any messages to send, if the now() time is past to time when I need to send the message from 'mailing_queue_table'. In one try I send only 100 email messages.
The problems starts there, when user is online and is reading messages already on the fly. For example, user receives a message on 8:05, script, that collects unreads count (1st point) runs on 8:10, but user then reads this message on 8:12, then stored personalised message (3rd point) has false information laying there, and then I have to run again delete query to unset it from queue.
While writing this problem, I had a thought about that I could check for that if user has been online in some sort of interval, and then check should I send him a notification, or he is so active on site, that there is no necessary to store on queue and then send the mail.
Maybe you have some good literature or tutorial to do these things properly. For example, Facebook is great example of sending notifications, but good material is hard to find. Maybe you have some ideas, that you have went through in your programming life and could share with us.
Thanks,
/Rob
I'm making a database for labors resident Visa, I want to make a reminder on expiry date, if a visa expire at 1/1/2012, I Want PHP to send me reminder as email, or pop up message
EDIT
thank you guys, but let's forget about the reminder via email, let's say I created a table (ID,name,issue date,expiry date) (1,joe,11/11/2009,12/11/2011) and all data are displayed in a table.. what I want to do is, I want the color of the table row to turn red in case its expired.
I hope I explained it right..
create a page to check the expiry date and do necessary action. set a cron job to call the page every one hour or a time suitable for you.
Search for cron job and how to setup it in your control panel using your search engine
Run a cron job every day to fetch the list of visas expiring on specific date, and send a mail to all the results.
More info about cron
http://www.sitepoint.com/introducing-cron/
Check this url which could be the basis of your script, and easily merged. http://www.devarticles.com/c/a/MySQL/Setup-Your-Personal-Reminder-System-Using-PHP/1/
You need to write the cronjob .. that make an email to you after a specific time
You can read more about cronjob from here ...
cronjob
Sandeep and Joby provided your solution. I would like to add this as another suggestion.
Use cron job to schedule a process that will check for visas expiring everyday. Then send an email appropriately.
To send an email easily, you can use PHPMailer library. It has a lot of built-in facility which are ready for use.
I am working on a web-application to make an SMS Reminder service, which takes various inputs from the user, like the user's name, his number, and the time he wants the reminder. The reminder is then sent through an SMS. I have the SMS Gateway part figured out for which I am using Zeep Mobile's API. I wanted to know how I can send an SMS on the time input by the user.
The database would have the user-id and the time, and I need to get my application to send an sms at the time. Any tutorials on similar lines would be great help.
Thanks in advance
Let's say your reminder interval is 1 minute and you are deploying on Linux.
1) Set up a cron-job to check your database every minute for possible reminders
2) If there are reminders to be sent, execute your sending script.
3) Mark sent reminders with a status (or similar) so you don't send them again.
Depending on what server your application is deployed, you would need to run some kind of service that would run continuously and send SMS whenever one is due.
One note though, since repeated database access is costly, you may like to load up Reminders that would need to be sent in a short time. The database should be accesses periodically with a reasonable time interval.
HI all,
I have an account in getresponse.com
I want to send emails to the members in my mailing list after one hour of their joining.
Please tell me how can i do this
I don't really know what's that getresponse.com all about and what are your possibilities, but deducing from php tag:
Php scripts can't execute for an hour => you have to schedule this. You need some database(or at least a file or sth else) to store the information when someone joined and a cron script that's scheduled to run eg. every 5 minutes that checks your database and if the time is right sends an e-mail and then removes the entry from database.
Admin interface allows you to create a follow-up message received by subscriber no sooner than 1 day after their subscription, so you will most likely have to send it through their API call:
http://dev.getresponse.com/api-doc/#send_newsletter
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.
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:
Go into GMail.
At the top, click on "Calendar".
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).
This brings up a tabbed interface. I think it always brings you to the "Calendars" tab, but if it doesn't, click that tab.
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.
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
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.
Sending mass email using PHP
https://stackoverflow.com/questions/215736/how-do-i-send-bulk-mail-to-my-users-in-a-generic-fashion
Read those you will get some ideas.