Re: Scheduled emails



©® wrote:
When I used to host with Godaddy, they had a feature whereby you could
type an email and send it at a specific date and time - great for me to
send birthday wishes to people so I don't forget!
Now I am with Bluehost and they use CPanel but I don't see any feature
like that.
Is this something that can be accomplished in PHP? I am *very* new to
PHP so am newer than a newbie so hope someone can help.
Thanks



You need the php script that sends the mail to be run once in a while, usually
done as a cron job, if you don't have that possibility, things will be
depending on outside actions. If you have a site with enough users, you could
build the whole mail sending to the web pages, so that when a user visits a
page, a check is made if it's time to send a mail or not, if time, then send
it, this will of course generate the risk of multiple mails sent to the same
person, as it could be possible that more than one person is accessing the
page, trigger the sending of the mail before the mail has been removed from
the cue or marked as sent.
Of course you can have one page that sends mail and that one is periodically
loaded from another computer which you have cron job access, but in that case,
you can have the whole php stuff on that machine instead of your web hotel.
If you have shell access, then you can write an infinitive loop with sleep,
that once ever X minute checks the mail cue, and sends the mail if it time,
this script can be run in screen or background, so that you can log off the
shell (otherwise you need to be connected all the time).

In the long run, a cron job is the easy way, but most web hotels won't give
you any such access, same with shell accounts.

The code of a mail sender that reads input from file/database is quite simple
and you get all the information you need by reading the php.net online manual,
start with mail(), this function may be disabled, then you need a third party
package that provides you with a simple SMTP features.


--

//Aho
.



Relevant Pages

  • Re: Zip some folders and send by email
    ... zip selected folders and have the zip file emailed to myself. ... Not as a cron job or anything automated - it will be a option i will add ... IMHO its a lot easier to do from the shell than in PHP. ...
    (comp.lang.php)
  • Re: PHP [win32] & CLI Testers needed.
    ... written, lets just say to create shell emulation for now, and have ... My previous attempts to create the source below, ended with the loop ... finally resolve any issues due to this problem in PHP compatibility. ... Debug Warning: testforLinuxUser.php line 24 - stream_select: supplied argument is not a valid stream resource ...
    (php.general)
  • Re: set environment Path variable
    ... home directory it is missing. ... indicates that the php command can't be found. ... php under the directory in which you installed the php package. ... When the shell ...
    (comp.unix.shell)
  • Re: Cron and HTML
    ... cron job to not execute? ... This file is run via a cron job. ... I removed all the html at the end of the php section. ...
    (comp.lang.php)
  • Re: [PHP] Cron php & refresh
    ... Then a regular cron job runs a php page to select the data ... My original vision was to have the script do about 50 mails, ... which an individual may exclusively possess as long as he keeps it to ...
    (php.general)