Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending mail automatically.

Posted on 2001-06-05
5
Medium Priority
?
237 Views
Last Modified: 2008-03-17
Currently on my website i'm using PHP and MySQL.  What I would like to do is have sendmail on my Linux server send out mails automatically according to a date stored in MySQL.

For example.

Activity: Baseball
Date: June 24, 2001

When the day rolls around to June 24, my PHP script will email out to everyone of the above activity.  It should be all automated and nothing done after initial entry.  I guess the problem i'm having is: how do I build my PHP script so it runs in the background and only sends once.  I'm not sure if this is PHP / MySQL issue OR if it's a sendmail issue.

Can anyone help me shed some light on this?

Thanks,
myuen
0
Comment
Question by:myuen
5 Comments
 
LVL 4

Expert Comment

by:ykf2000
ID: 6158206
Hi,

What you can do is to use crontab and schedule to trigger the running of the script everyday. The script should check for the date and send neccesary mails. If your PHP is a CGI module than u can run it directly through crontab, else trigger it by running lynx on it.
0
 
LVL 8

Accepted Solution

by:
us111 earned 80 total points
ID: 6158741
install php as cgi-bin (default compilation)

1. create a phpscript
#!/pathtophp/bin/php
<?
 here is the script, check date, send mail....
?>

2. save the file as yourfile.php

3. chmod 700 yourfile.php

4. create a crontab file that you run everyday: crontab.txt
0 0 * * * /pathto_yourfile.php

5. crontab crontab.txt
0
 
LVL 4

Expert Comment

by:kalosi
ID: 6162738
Hello,

you even don't need to install php as cgi-bin. We are using
an alternative solution:

download the libwww perlmodule. After building it it creates
the following binaries:

GET and POST. these binaries represent the basic HTTP protocol commands.

create a date checker in the script which you are useing as described abow and then simply put a line like this to your crontab file

0 0 * * * GET -t 1000 http://path_to_script/script_name.php >
 /redirect_the_output/for_some_logging

the -t switch is the timeout of the GET request

bye

0
 
LVL 8

Expert Comment

by:us111
ID: 6162756
didn't know this solution.
But the problem is that if you need to have your script secured you cannot because you call an URL. So you php script must be into the web root. With php (as cgi-bin) you can have it where you wish
0
 

Expert Comment

by:timothyha
ID: 6163501
I think you might try another option if you don't have access to CRON. You can put that mailing script code in the index.php of your site. Every visitor then will trigger the check whether email has been sent or not. I don't think if you add too much time to that ONE good visitor who will work for you. But in case on June 24 nobody comes to your site, email will not be sent out :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question