PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > how to send message auto matically
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
how to send message auto matically

Réponse
 
LinkBack Outils de la discussion
Vieux 26/03/2008, 05h30   #1
anbu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how to send message auto matically

there in one database and one table that have three field one is
name and another one is date
and last is email address

data are stored in following ways

name date email address

anbu 2008-03-26 something@gmail.com


automatically tomrrow (2008-03-27) send message to that email
address(something@gmail.com)

give solution

thank you
  Réponse avec citation
Vieux 26/03/2008, 10h27   #2
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to send message auto matically

Hi,

Here is the script:

--- begin mailer.php ---
<?php

error_reporting(E_ALL | E_STRICT);

require_once('MDB2.php');
require_once('MDB2/Date.php');

class Mailer
{
var $db;

function getDb()
{
if (empty($this->db)) {
$dsn = 'mysql://u:p@h/d';
$this->db = MDB2::singleton($dsn);
$this->db->setOption('portability', MDB2_PORTABILITY_FIX_CASE);
$this->db->setFetchMode(MDB2_FETCHMODE_ASSOC);
$this->db->loadModule('Extended');
}
return $this->db;
}

function process()
{
PEAR::setErrorHandling(PEAR_ERROR_DIE);
if (isset($_GET['action']) && $_GET['action'] == 'send') {
$this->send();
}
}

function send()
{
echo "<p>\n";
$this->log("Starting mailer.");
$begin = mktime(0, 0, 0, date('n'), date('j') - 1, date('Y'));
$end = mktime(23, 59, 59, date('n'), date('j') - 1, date('Y'));
$this->log("Date range: " . date('Y-m-d H:i:s', $begin) . ' - ' .
date('Y-m-d H:i:s', $end) . '.');

$db = $this->getDb();
$sql = 'select name, email, date from subscriber where ' .
'date >= :begin and date <= :end';
$query = $db->prepare($sql);
$params = array('begin' => MDB2_Date::unix2Mdbstamp($begin),
'end' => MDB2_Date::unix2Mdbstamp($end));
$rs = $query->execute($params);

while ($subscriber = $rs->fetchRow()) {
$this->sendTo($subscriber);
}

$this->log("Finished mailer.");
echo "</p>\n";
}

function sendTo($subscriber)
{
$this->log("Seding e-mail to {$subscriber['name']} at " .
$subscriber['email'] . ".");
$msg = "Dear {$subscriber['name']},\n\n";
$msg .= "This is your automated notice.\n";
mail($subscriber['email'], 'Notice', $msg, 'From:
info@example.test');
}

function log($msg)
{
echo date('[Y-m-d H:i:s]');
echo ' [mailer] ';
echo $msg;
echo "<br>\n";
}
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Mailer</title>
</head>
<body>
<h1>Mailer</h1>

<?php

$mailer = new Mailer;
$mailer->process();

?>

<p>Click below to send e-mails.</p>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']) ?>">
<input type=hidden name=action value="send">
<input type=submit value=Send>
</form>
</body>
</html>
--- end mailer.php ---

Run this script daily but putting something like this line in your
crontab:

30 8 * * * /usr/bin/lynx -source 'http://example.test/admin/mailer.php?
action=send' 2>&1

Regards,

John Peters

On Mar 26, 12:30 am, anbu <anbuphpcod...@gmail.com> wrote:
> there in one database and one table that have three field one is
> name and another one is date
> and last is email address
>
> data are stored in following ways
>
> name date email address
>
> anbu 2008-03-26 someth...@gmail.com
>
> automatically tomrrow (2008-03-27) send message to that email
> address(someth...@gmail.com)
>
> give solution
>
> thank you


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h20.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,40652 seconds with 10 queries