![]() |
| ||
| PHP reminder E-mail - Cron job to run the script Hello everyone, Well i've just searched the forum to see if my question has been answered prioer to posting, but seem to find the answer. Well basicly i've created a script to help me monitor and maintain the domain names my company owns (1000's) I've virtually finished it but i am missing one bit - the auto email's reminding me when a domain will expire - I know you get the reminders from registrars but they only send to myself and others need to know this informaiton eg: Marketing, IT dept and i dont want them to have access to the domain contral panel at the registrar. So i've been looking up possible ways to generate an automated email - but to no avail. I have the following fields in my database: domain_name, company_name, exp_date (Which is the expiry date in 0000-00-00format So i was wondering if a cron job script can be run daily to check the domains that will expire in the next 7 days. For example if a domain had a exp_date as 2008-05-16 when the script is run on the 2008-05-09 an email will be sent to telling me such a domain is expiring soon. If any 1 can point me in the right direction, i'd be very greatful Many thanks Dan |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Quote:
Which do you have problems with, writing the PHP script or adding the script to cron? |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Quote:
The cron will be the easy part - its just structuring the script that i'm finding difficult |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Quote:
Really depends on how you're updating the database. If you're updating just for the case of sending out emails when the domains expire, then you can just delete the rows in the db when you send out an email.. Your query: SELECT domain_name from domains_table where exp_date > NOW(); Iterate through each row, send email and remove row. Otherwise, you could add another column with the email send timeboolean. So your query would be something like:
Is that what you're trying to do? |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Well - the query i would use would be very similar to what you posted - where exp_date > NOW(); Once the domain has expired i dont intrend to delete the record from my database though. The way i thought it would work would be: When the domain is 1 week from expiring a query will be run checkin the dates in exp_date to see what domains are going to expire in 7 days Then if there is a domain(s) about to expire in 7 days it will send an email reminder informing myself - and other members of staff that its goin to expire: the email format will be something like this Staff members name(s) the following domain(s) will expire in 7 days example.com example.co.uk example.net Else no e-mail is sent until the cron job runs the next day Or something similar - not to familiar with the mail function though in php |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Quote:
that should work... PHP mail function. |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Been lookin at that php mail function today - was able to send a simple email using the examples that are provided still figuring out how to email results from my query to be sent via email ive structured a script below - it doesnt work but you can see what i am after <?php Not sure where i am going wrong :( |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Quote:
try doing some dumps (var_dump or print_r) of your $message variable in the while loop to see if you're getting what you want. |
| ||
| Re: PHP reminder E-mail - Cron job to run the script Hey digital-ether, thanks for responding to my thread again. I've been doing alot of reading and i've virtually clocked it Now when the email sends - instead of just sending one email with the results of the query, it will send alot more for example if the query returned 30 results it will send me 30 emails with each result of the query being in each email and i just want all results to appear one! Here is the code im using - 90% there! <? Where am i going wrong? Many thanks |
| All times are GMT -4. The time now is 4:06 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC