--- trunk/sender.pl 2005/05/16 22:32:58 32 +++ trunk/sender.pl 2005/05/24 16:44:34 49 @@ -19,7 +19,7 @@ In C something like: - mylist: "| /path/to/sender.pl --inbox=mylist" + mylist: "| cd /path/to && ./sender.pl --inbox=mylist" =head2 Command options @@ -40,7 +40,9 @@ "inbox=s" => \$opt->{'inbox'}, "debug" => \$debug, "verbose" => \$verbose, - "email=s" => \$opt->{'email'}, + "from=s" => \$opt->{'from'}, + "driver=s" => \$opt->{'email_send_driver'}, + "sleep=i" => \$opt->{'sleep'}, ); my $nos = new Nos( @@ -74,6 +76,9 @@ Adds new list. You can also feed list name as first line to C. +You can also add C<--from='Full name of list'> to specify full name (comment) +in outgoing e-mail. + =cut if ($list_name = $opt->{'new'}) { @@ -83,12 +88,13 @@ die "need e-mail address for list (as argument or on STDIN)\n" unless ($email); - my $l = $nos->_get_list($list_name) || $nos->_add_list( + my $id = $nos->new_list( list => $list_name, + from => ($opt->{'from'} || ''), email => $email, ) || die "can't add list $list_name\n"; - print "added list $list_name with ID ",$l->id,"\n"; + print "added list $list_name with ID $id\n"; =item --list[=list_name] @@ -112,9 +118,8 @@ foreach my $list (@lists) { print $list->name," <",$list->email,">\n"; - foreach my $user_on_list ($user_list->search(list_id => $list->id)) { - my $user = $users->retrieve( id => $user_on_list->user_id ); - print "\t",$user->full_name," <", $user->email, ">\n"; + foreach my $u ($nos->list_members( list => $list->name )) { + print "\t",$u->{'name'}, " <", $u->{'email'}, ">\n"; } } @@ -127,9 +132,6 @@ email@example.com Optional full name of person dpavlin@rot13.org Dobrica Pavlinusic -You may use C<--email> parametar at any time to set From: e-mail address for list. -B. - =cut } elsif ($list_name = $opt->{'add'}) { @@ -190,7 +192,7 @@ my $msg = $m->message_id->message; $msg =~ s/\s+/ /gs; - $l .= sprintf(" %-10s %15s : ", $m->list_id->name, $date); + $l .= sprintf(" %-15s %15s : ", $m->list_id->name, $date); $l .= substr($msg, 0, 79 - length($l)); print "$l\n"; @@ -204,11 +206,21 @@ Send e-mails waiting in queue, or with optional argument, just send messages for single list. +Optional argument C<--driver=smtp> forces sending using SMTP server at +localhost (127.0.0.1). + +Optional argument C<--sleep=42> defines that sender will sleep 42 seconds +between sending e-mail. + =cut } elsif (defined($list_name = $opt->{'send'})) { - $nos->send_queued_messages($list_name); + $nos->send_queued_messages( + list => $list_name, + driver => $opt->{'email_send_driver'}, + sleep => $opt->{'sleep'}, + ); =item --inbox=list_name @@ -217,9 +229,18 @@ =cut -} elsif ($opt->{'inbox'}) { +} elsif ($list_name = $opt->{'inbox'}) { + + my $message; + while(<>) { + $message .= $_; + } + + $nos->inbox_message( + list => $list_name, + message => $message, + ) || die "can't receive message for list $list_name"; - warn "inbox option is not implemented"; } else { die "see perldoc $0 for help\n"; @@ -241,10 +262,6 @@ Dump more info on screen. -=item --email - -Used to specify e-mail address where needed. - =back