/[notice-sender]/trunk/Nos.pm
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/Nos.pm

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

revision 71 by dpavlin, Mon Aug 22 19:25:24 2005 UTC revision 74 by dpavlin, Wed Aug 24 17:19:16 2005 UTC
# Line 16  our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all' Line 16  our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'
16  our @EXPORT = qw(  our @EXPORT = qw(
17  );  );
18    
19  our $VERSION = '0.6';  our $VERSION = '0.7';
20    
21  use Class::DBI::Loader;  use Class::DBI::Loader;
22  use Email::Valid;  use Email::Valid;
# Line 62  encoded) or anything else. Line 62  encoded) or anything else.
62  It will just queue your e-mail message to particular list (sending it to  It will just queue your e-mail message to particular list (sending it to
63  possibly remote Notice Sender SOAP server just once), send it out at  possibly remote Notice Sender SOAP server just once), send it out at
64  reasonable rate (so that it doesn't flood your e-mail infrastructure) and  reasonable rate (so that it doesn't flood your e-mail infrastructure) and
65  track replies.  keep track replies.
66    
67  It is best used to send smaller number of messages to more-or-less fixed  It is best used to send small number of messages to more-or-less fixed
68  list of recipients while allowing individual responses to be examined.  list of recipients while allowing individual responses to be examined.
69  Tipical use include replacing php e-mail sending code with SOAP call to  Tipical use include replacing php e-mail sending code with SOAP call to
70  Notice Sender. It does support additional C<ext_id> field for each member  Notice Sender. It does support additional C<ext_id> field for each member
# Line 72  which can be used to track some unique i Line 72  which can be used to track some unique i
72  particular user.  particular user.
73    
74  It comes with command-line utility C<sender.pl> which can be used to perform  It comes with command-line utility C<sender.pl> which can be used to perform
75  all available operation from scripts (see C<perldoc sender.pl>).  all available operation from scripts (see C<sender.pl --man>).
76  This command is also useful for debugging while writing client SOAP  This command is also useful for debugging while writing client SOAP
77  application.  application.
78    
# Line 120  sub new { Line 120  sub new {
120  }  }
121    
122    
123  =head2 new_list  =head2 create_list
124    
125  Create new list. Required arguments are name of C<list>, C<email> address  Create new list. Required arguments are name of C<list>, C<email> address
126  and path to C<aliases> file.  and path to C<aliases> file.
127    
128   $nos->new_list(   $nos->create_list(
129          list => 'My list',          list => 'My list',
130          from => 'Outgoing from comment',          from => 'Outgoing from comment',
131          email => 'my-list@example.com',          email => 'my-list@example.com',
# Line 139  Calls internally C<_add_list>, see detai Line 139  Calls internally C<_add_list>, see detai
139    
140  =cut  =cut
141    
142  sub new_list {  sub create_list {
143          my $self = shift;          my $self = shift;
144    
145          my $arg = {@_};          my $arg = {@_};
# Line 158  sub new_list { Line 158  sub new_list {
158  }  }
159    
160    
161  =head2 delete_list  =head2 drop_list
162    
163  Delete list from database.  Delete list from database.
164    
165   my $ok = delete_list(   my $ok = drop_list(
166          list => 'My list'          list => 'My list'
167          aliases => '/etc/mail/mylist',          aliases => '/etc/mail/mylist',
168   );   );
# Line 171  Returns false if list doesn't exist. Line 171  Returns false if list doesn't exist.
171    
172  =cut  =cut
173    
174  sub delete_list {  sub drop_list {
175          my $self = shift;          my $self = shift;
176    
177          my $args = {@_};          my $args = {@_};
# Line 267  List all members of some list. Line 267  List all members of some list.
267          list => 'My list',          list => 'My list',
268   );   );
269    
270  Returns array of hashes with user informations like this:  Returns array of hashes with user information like this:
271    
272   $member = {   $member = {
273          name => 'Dobrica Pavlinusic',          name => 'Dobrica Pavlinusic',
# Line 939  sub new { Line 939  sub new {
939  }  }
940    
941    
942  =head2 NewList  =head2 CreateList
943    
944   $message_id = NewList(   $message_id = CreateList(
945          list => 'My list',          list => 'My list',
946          from => 'Name of my list',          from => 'Name of my list',
947          email => 'my-list@example.com'          email => 'my-list@example.com'
# Line 949  sub new { Line 949  sub new {
949    
950  =cut  =cut
951    
952  sub NewList {  sub CreateList {
953          my $self = shift;          my $self = shift;
954    
955          my $aliases = $nos->{'aliases'} || croak "need 'aliases' argument to new constructor";          my $aliases = $nos->{'aliases'} || croak "need 'aliases' argument to new constructor";
956    
957          if ($_[0] !~ m/^HASH/) {          if ($_[0] !~ m/^HASH/) {
958                  return $nos->new_list(                  return $nos->create_list(
959                          list => $_[0], from => $_[1], email => $_[2],                          list => $_[0], from => $_[1], email => $_[2],
960                          aliases => $aliases,                          aliases => $aliases,
961                  );                  );
962          } else {          } else {
963                  return $nos->new_list( %{ shift @_ }, aliases => $aliases );                  return $nos->create_list( %{ shift @_ }, aliases => $aliases );
964          }          }
965  }  }
966    
967    
968  =head2 DeleteList  =head2 DropList
969    
970   $ok = DeleteList(   $ok = DropList(
971          list => 'My list',          list => 'My list',
972   );   );
973    
974  =cut  =cut
975    
976  sub DeleteList {  sub DropList {
977          my $self = shift;          my $self = shift;
978    
979          my $aliases = $nos->{'aliases'} || croak "need 'aliases' argument to new constructor";          my $aliases = $nos->{'aliases'} || croak "need 'aliases' argument to new constructor";
980    
981          if ($_[0] !~ m/^HASH/) {          if ($_[0] !~ m/^HASH/) {
982                  return $nos->delete_list(                  return $nos->drop_list(
983                          list => $_[0],                          list => $_[0],
984                          aliases => $aliases,                          aliases => $aliases,
985                  );                  );
986          } else {          } else {
987                  return $nos->delete_list( %{ shift @_ }, aliases => $aliases );                  return $nos->drop_list( %{ shift @_ }, aliases => $aliases );
988          }          }
989  }  }
990    
# Line 1020  sub AddMemberToList { Line 1020  sub AddMemberToList {
1020    
1021  Returns array of hashes with user informations, see C<list_members>.  Returns array of hashes with user informations, see C<list_members>.
1022    
 Returning arrays from SOAP calls is somewhat fuzzy (at least to me). It  
 seems that SOAP::Lite client thinks that it has array with one element which  
 is array of hashes with data.  
   
1023  =cut  =cut
1024    
1025  sub ListMembers {  sub ListMembers {
# Line 1084  sub AddMessageToList { Line 1080  sub AddMessageToList {
1080          }          }
1081  }  }
1082    
1083    =head1 UNIMPLEMENTED FUNCTIONS
1084    
1085    This is a stub for documentation of unimplemented functions.
1086    
1087    =head2 MessagesReceived
1088    
1089     my @result = MessagesReceived(
1090            list => 'My list',
1091            email => 'jdoe@example.com',
1092     );
1093    
1094    You can specify just C<list> or C<email> or any combination of those.
1095    
1096    It will return array of hashes with following structure:
1097    
1098     {
1099            id => 42,                       # unique ID of received message
1100            list => 'My list',              # useful only of filtering by email
1101            ext_id => 9999,                 # ext_id from message user
1102            email => 'jdoe@example.com',    # e-mail of user
1103            bounced => 0,                   # true value if message is bounce
1104            date => '2005-08-24 18:57:24',  # date of recival in ISO format
1105     }
1106    
1107    =head2 MessagesReceivedByDate
1108    
1109    =head2 MessagesReceivedByDateWithContent
1110    
1111    =head2 ReceivedMessasgeContent
1112    
1113    Return content of received message.
1114    
1115     my $mail_body = ReceivedMessageContent( id => 42 );
1116    
1117    =cut
1118    
1119    
1120    
1121    
1122  ###  ###
1123    
1124    =head1 NOTE ON ARRAYS IN SOAP
1125    
1126    Returning arrays from SOAP calls is somewhat fuzzy (at least to me). It
1127    seems that SOAP::Lite client thinks that it has array with one element which
1128    is array of hashes with data.
1129    
1130  =head1 EXPORT  =head1 EXPORT
1131    
1132  Nothing.  Nothing.

Legend:
Removed from v.71  
changed lines
  Added in v.74

  ViewVC Help
Powered by ViewVC 1.1.26