Hello All,
I'm writing a program that will allow users to construct an email message
and schedule when the message will be sent (eg for times when the mail
server is less busy). I solved the scheduling program by subtracting the
"send time" from the "current time" giving me X seconds to wait. Then I use
sleep($pause_length) before the next part of the program--mailing--executes.
However, I also want the user to receive a Web page that says, yeah, it
worked. When I run the program, everything does work, except that the
sleep() seems to invoke before the Web page is constructed.
I'd be happy to hear if there is a better solution to this problem than
sleep(), or why sleep() is preventing the page from being created. Here's
the relevant code:
$time_current = time();
$time_send = timelocal(0, 0, $hour, $day, $month-1, $year-1900);
$pause_length = ($time_send - $time_current);
if ($pause_length < 0)
{
print $q->header( "text/html" ),
$q->start_html( -title => "Error" ),
$q->h2( "Date and time problem" ),
$q->p( "You have entered a date and/or time in the past. Please hit the
Back button and try again." ),
$q->end_html;
exit;
}
else
{
print $q->header( "text/html" ),
$q->start_html( -title => "output" ),
$q->h2( "Ouput" ),
$q->p( "Here's what you wrote: $message" ),
$q->end_html;
}
mail();
exit;
sub mail
{
sleep($pause_length);
open SENDMAIL, "| /usr/lib/sendmail -oi -t"
|| die "Can't fork for sendmail: $!\n";
print SENDMAIL "From: $sender_email \n";
print SENDMAIL "To: $sender_email \n";
print SENDMAIL "Bcc: @recipients";
print SENDMAIL "Reply-to: $reply_to \n";
print SENDMAIL "Subject: $subject \n";
print SENDMAIL "This messages is from: $sender_name, $sender_email\n";
print SENDMAIL "$message \n";
close(SENDMAIL)
|| warn "sendmail didn't close nicely";
}
*********************************
Lesli LaRocco
Systems Administrator
Ithaca College
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]