Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: mail counter

by skazat (Chaplain)
on Jan 22, 2007 at 07:14 UTC ( [id://595874]=note: print w/replies, xml ) Need Help??


in reply to mail counter

I know how to do all the counting and resetting stuff. Does anyone know how to make the script look like a sendmail like program as far as PHP’s mail functions are concerned?

Ah, I see, you're basically asking how to make the interface to your queuing system, which is basically:

* Keep a count of how many messages go out in x amount of time,

* Queue up messages that can't go out after the limit has been reached

* Reset counter after x amount

* Send awaiting messages,

* etc,

I've always used Getopt::Long for command line interfaces. To emulate what you'd give to sendmail, you'd do something like:

#!/usr/bin/perl use Getopt::Long; my $sendmail = '/usr/sbin/sendmail'; my $f_flag = undef; my $t_flag = undef; my $i_flag = undef; my $o_flag = undef; GetOptions("f=s" => \$f_flag, "t" => \$t_flag, "i" => \$i_flag, "o" => \$o_flag, ); # Skipping the queue/count stuff for laziness... my $sendmail_w_flags = $sendmail; if($f_flag){ $sendmail_w_flags .= ' -f'.$f_flag; } if($t_flag){ $sendmail_w_flags .= ' -t';; } if($i_flag){ $sendmail_w_flags .= ' -i';; } if($o_flag){ $sendmail_w_flags .= ' -o';; } my $message = <STDIN>; open(MAIL, '|' . $sendmail_w_flags) or die $!; print MAIL $message or die $!; close MAIL or die $!;
(untested)

 

-justin simoni
skazat me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://595874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found