Yasen Petrov wrote at Mon, 08 Jul 2002 20:29:20 +0200:

> Hi all,
> my problem is that I want to send an e-mail every day, but when I try to iterate, 
>the unix perl
> wants to see all the iterations and then execute them at once, while this isn't the 
>same on
> windows. This means I can't send an e-mail every day this way below:
> 
> #!usr/bin/perl

use strict;

> use warnings;
> use CGI::Carp qw(fatalsToBrowser);
> 
> my $mailprogram = "/usr/lib/sendmail";
> my $rec = '[EMAIL PROTECTED]';
> my $i = 0;
> 
> 
> while ($i < 300)

300 mails to the same person. Wow!
However, it's better written as
for (1 .. 300) {
               ^^
(Don't forget to start a new block with "{")

> 
>  open (MAIL,"|$mailprogram -t");
                                 ^^^^^^^^^^^^
                                 or die "Can't open mailprogram";

Without the -oi option,
the mail ends on the first line with only a single dot.

>  print MAIL "To: $rec\n";
>  print MAIL "From: Yasen_Petrov\n";
>  print MAIL "Subject: Ads\n";

Between the header and the body,
there must be an empty line.

>  print MAIL "Some text\n";
>  sleep 60*60*24; # 24 hours

I don't think that the most web servers let a program 
so long at life. Many webservers kill the program after 3 minutes or so.

>  close MAIL;

It's important first to close and then to sleep.

>  $i++;
>  print "Content-type: text/html\n\n";
>  print "You have just send an e-mail to $rec\n";
> }
> }
> If anyone can help, I'll be very grateful. Thanks.
 
Best Wishes,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to