I use perl for this.....

Something like this:

----------------------------------------------
#!/usr/bin/perl
use MIME::Base64;
use Mail::Sendmail 0.77;

$email = '[EMAIL PROTECTED]';
$subject = 'some stuff here';
$entire_msg = `/usr/local/mysql/bin/mysql -H -e 'some query here'
somedatabase`;
$mail_result = mail_out($email, $subject , $entire_msg);

sub mail_out {
        local ($to,$sub,$msg) = @_;
        local(%mail) = (
                SMTP => $smtp_server,
                from => '[EMAIL PROTECTED]',
                to => $to,
                subject => $sub,
                Message => $msg
                );
        $mail{'Content-type'} = 'text/html';
        $mail{'Return-path'} = '[EMAIL PROTECTED]';
        return sendmail(%mail);
}
## Disclaimer: this code is meant as a guide only.  No responsibility will
be assumed by author if it fails to compile, breaks, or blows up your server
etc.. having said that it should work :)
----------------------------------------------

A

-----Original Message-----
From: Dan Tappin [mailto:[EMAIL PROTECTED]] 
Sent: 12 February 2003 16:37
To: [EMAIL PROTECTED]
Subject: Generating an automatic e-mail via MySQL


Does any one have a suggestion on running a daily / weekly e-mail 
notification based on results from a MySQL query?

I have a table with date sensitive rows.  The idea that as rows become 
stale (they were created / updated more than a week or month ago) the 
owner of the row is sent an e-mail with a summary of the stale items or 
even just a link back to a web page for updating.

The e-mail addresses would come from a related 'user' table.  The stale 
data table would have the 'user' id in a column for a JOIN statement.

I have a feeling that I will get a few 'buy a PERL book' suggestions 
which is fine but I am wondering if there is another method.  The same 
server is running Apache and PHP.  Could I run this from the command 
line using PHP?

In the end I would just like a simple CRON script that runs each day to 
send the notifications.

Any first thoughts?

Thanks,

Dan


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to