Sending an email programmed with PHP

Asked

Viewed 1,675 times

2

All right, folks, I’m new here and I have a very peculiar question. I am developing a system (Codeigniter + Mysql) that records some events and should send an email at a predefined date, around eight or nine months ahead. How I can schedule the sending of this email so that when this date comes the email is sent without user intervention?

  • Celson, welcome to Stack Overflow. You can use cron Jobs for this. We already have several questions here related to this, this one for example.

2 answers

1

Many systems happen this, have an event that will be on a specific date and have to fire an email at a certain period before to notify.

What I did was create a cronjob and this routine of mine calls a controller/metodo that makes a reading in the table that has the events and with this trigger the emails.

I advise taking a look at the documentation itself http://www.codeigniter.com/user_guide/general/cli.html

0

What I would do is the following, create a date field in this table and this field will receive that date that will be to define the sending day, create a basic PHP file and using only PHP without any HTML and in this file you create a function that searches this data field and check if it is equal to the current date and if it is you fire the Email to the person.

This file that takes care of sending you create a task in your hosting to run it from time to time there is automatic sending without human intervention.

If you have any doubts about how to do all this just give a touch.

  • I even understood the use of crontab to automate the task, but how to "run" the . php file if it is not executable? Could you show me some example?

  • The easiest way would be something similar to the link example: http://www.cybernetfx.com/clientes/knowledgebase.php?action=displayarticle&id=81

  • Then you go to your hosting and check if it has this service, yes php is not executable but the task schedule goes there and "runs" your php to run in the background and so it "runs" everything you have in the php file and that’s why you can’t have html inside it has to be pure php.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.