This topic is locked

How to make a reminder that sends an email on a certain date?

4/5/2008 5:04:08 AM
PHPRunner General questions
S
shoppy author

In my customer_view I have a textfield with information about a task for a client.

Under this textfield I have a datefield.
I want to use this datefield to remind me of something I have to to for this client.
Is it possible to insert a script that emails a warning to the user that entered the date?
If it is to complicated to do that, is it then just possible to email to a fixed emailadres?
At this moment I use 'Tasks' in OUTLOOK to do this. Don't like this!

Admin 4/6/2008

You need to use external scheduler like CRON for this purpose.
Write a script that checks the date and sends an email. Use cron to run this script on timely fashion i.e. once a day.

S
shoppy author 4/10/2008

Hi,
We solved this 'problem' with the following script and let Windows tasks run it every morning before office time!

But as you can see it sends the reminder to a fixed e-mail adres. (in this case to jdewinkel@winkel-advies.nl).
[codebox]<?php

ini_set('SMTP','post.demon.nl');
$server = 'localhost';

$gebruiker = 'blah';

$wachtwoord = 'blah';

$database = 'advies';
$email = 'jdewinkel@winkel-advies.nl';
if(mysql_connect($server,$gebruiker,$wachtwoord))

{

if(mysql_select_db($database))

{

$query = "SELECT Naam, Voornaam, Voorvoegsel, Voortgang, Reminder FROM `_klant` WHERE Reminder <= NOW()";

$result = mysql_query($query);
if($result && mysql_num_rows($result) > 0)

{

while($row = mysql_fetch_assoc($result))

{

$headers .= 'From: reminder@synoptico.nl'.PHP_EOL;

$headers .= 'To: '.$email.PHP_EOL;

$headers .= 'X-Mailer: PHP v'.phpversion().PHP_EOL;

$headers .= 'X-Originating-IP: '.$_SERVER['REMOTE_ADDR'].PHP_EOL;

$headers .= 'MIME-Version: 1.0'.PHP_EOL;

$headers .= 'Content-Type: text/plain; charset=UTF-8'.PHP_EOL;
$bericht .= 'Beste John,'.PHP_EOL.PHP_EOL;

$bericht .= 'Er staat nog een reminder open voor '.$row['Reminder'].PHP_EOL.PHP_EOL;

$bericht .= 'Klant: '.$row['Voornaam'].' '.$row['Voorvoegsel'].' '.$row['Naam'].PHP_EOL.PHP_EOL;

$bericht .= strip_tags($row['Voortgang']);
if(mail($email,'Reminder: '.$row['Naam'], $bericht, $headers))

{

echo 'Verstuurd!'.PHP_EOL;

}else{

echo 'Mislukt'.PHP_EOL;

}

}

}else{

echo '<p>Sorry, ik heb geen klanten gevonden!</p>';

}
}else{

echo '<p>Sorry, ik kon geen verbinding maken met de databasetabel!</p>';

}

}else{

echo '<p>Sorry, ik kon geen verbinding maken met de databaseserver!</p>';

}[/codebox]
What I like is that the e-mail will be send to the user that filled in the date of this reminder!

(and now a part that is hard to explain for me in english)

The usersnames of the users that can log in are in the table '_klant'.

The client has an unique ID (KlantID) and two of the fields within this table '_klant' are the field that contains the login name (Inlognaam) and the other contains the given password (Password).
Is this possible?