/[notice-sender]/trunk/sender.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/sender.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 32 by dpavlin, Mon May 16 22:32:58 2005 UTC revision 47 by dpavlin, Tue May 24 14:02:05 2005 UTC
# Line 40  my $result = GetOptions( Line 40  my $result = GetOptions(
40          "inbox=s" => \$opt->{'inbox'},          "inbox=s" => \$opt->{'inbox'},
41          "debug" => \$debug,          "debug" => \$debug,
42          "verbose" => \$verbose,          "verbose" => \$verbose,
43          "email=s" => \$opt->{'email'},          "from=s" => \$opt->{'from'},
44            "driver=s" => \$opt->{'email_send_driver'},
45  );  );
46    
47  my $nos = new Nos(  my $nos = new Nos(
# Line 74  my $list_name; Line 75  my $list_name;
75    
76  Adds new list. You can also feed list name as first line to C<STDIN>.  Adds new list. You can also feed list name as first line to C<STDIN>.
77    
78    You can also add C<--from='Full name of list'> to specify full name (comment)
79    in outgoing e-mail.
80    
81  =cut  =cut
82    
83  if ($list_name = $opt->{'new'}) {  if ($list_name = $opt->{'new'}) {
# Line 83  if ($list_name = $opt->{'new'}) { Line 87  if ($list_name = $opt->{'new'}) {
87    
88          die "need e-mail address for list (as argument or on STDIN)\n" unless ($email);          die "need e-mail address for list (as argument or on STDIN)\n" unless ($email);
89    
90          my $l = $nos->_get_list($list_name) || $nos->_add_list(          my $id = $nos->new_list(
91                  list => $list_name,                  list => $list_name,
92                    from => ($opt->{'from'} || ''),
93                  email => $email,                  email => $email,
94          ) || die "can't add list $list_name\n";          ) || die "can't add list $list_name\n";
95    
96          print "added list $list_name with ID ",$l->id,"\n";          print "added list $list_name with ID $id\n";
97    
98    
99  =item --list[=list_name]  =item --list[=list_name]
# Line 112  on that list. Line 117  on that list.
117    
118          foreach my $list (@lists) {          foreach my $list (@lists) {
119                  print $list->name," <",$list->email,">\n";                  print $list->name," <",$list->email,">\n";
120                  foreach my $user_on_list ($user_list->search(list_id => $list->id)) {                  foreach my $u ($nos->list_members( list => $list->name )) {
121                          my $user = $users->retrieve( id => $user_on_list->user_id );                          print "\t",$u->{'name'}, " <", $u->{'email'}, ">\n";
                         print "\t",$user->full_name," <", $user->email, ">\n";  
122                  }                  }
123          }          }
124    
# Line 127  argument) or read from C<STDIN>. List sh Line 131  argument) or read from C<STDIN>. List sh
131   email@example.com      Optional full name of person   email@example.com      Optional full name of person
132   dpavlin@rot13.org      Dobrica Pavlinusic   dpavlin@rot13.org      Dobrica Pavlinusic
133    
 You may use C<--email> parametar at any time to set From: e-mail address for list.  
 B<This seems somewhat cludgy, and it will probably change in future>.  
   
134  =cut  =cut
135    
136  } elsif ($list_name = $opt->{'add'}) {  } elsif ($list_name = $opt->{'add'}) {
# Line 190  add C<--verbose> flag, it will display a Line 191  add C<--verbose> flag, it will display a
191                          my $msg = $m->message_id->message;                          my $msg = $m->message_id->message;
192                          $msg =~ s/\s+/ /gs;                          $msg =~ s/\s+/ /gs;
193    
194                          $l .= sprintf(" %-10s %15s : ", $m->list_id->name, $date);                          $l .= sprintf(" %-15s %15s : ", $m->list_id->name, $date);
195                          $l .= substr($msg, 0, 79 - length($l));                          $l .= substr($msg, 0, 79 - length($l));
196    
197                          print "$l\n";                          print "$l\n";
# Line 204  add C<--verbose> flag, it will display a Line 205  add C<--verbose> flag, it will display a
205  Send e-mails waiting in queue, or with optional argument, just send messages  Send e-mails waiting in queue, or with optional argument, just send messages
206  for single list.  for single list.
207    
208    Optional argument C<--driver=smtp> forces sending using SMTP server at
209    localhost (127.0.0.1).
210    
211  =cut  =cut
212    
213  } elsif (defined($list_name = $opt->{'send'})) {  } elsif (defined($list_name = $opt->{'send'})) {
214    
215          $nos->send_queued_messages($list_name);          $nos->send_queued_messages($list_name, $opt->{'email_send_driver'});
216    
217    
218  =item --inbox=list_name  =item --inbox=list_name
# Line 217  Feed incomming message back into notice Line 221  Feed incomming message back into notice
221    
222  =cut  =cut
223    
224  } elsif ($opt->{'inbox'}) {  } elsif ($list_name = $opt->{'inbox'}) {
225    
226            my $message;
227            while(<>) {
228                    $message .= $_;
229            }
230    
231            $nos->inbox_message(
232                    list => $list_name,
233                    message => $message,
234            ) || die "can't receive message for list $list_name";
235    
         warn "inbox option is not implemented";  
236    
237  } else  {  } else  {
238          die "see perldoc $0 for help\n";          die "see perldoc $0 for help\n";
# Line 241  Turn on debugging output from C<Class::D Line 254  Turn on debugging output from C<Class::D
254    
255  Dump more info on screen.  Dump more info on screen.
256    
 =item --email  
   
 Used to specify e-mail address where needed.  
   
257  =back  =back
258    
259    

Legend:
Removed from v.32  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.26