40 |
|
|
41 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
42 |
|
|
43 |
Core module for notice sender's functionality. |
Notice sender is mail handler. It is not MTA, since it doesn't know how to |
44 |
|
receive e-mails or send them directly to other hosts. It is not mail list |
45 |
|
manager because it requires programming to add list members and send |
46 |
|
messages. You can think of it as mechanisam for off-loading your e-mail |
47 |
|
sending to remote server using SOAP service. |
48 |
|
|
49 |
|
It's concept is based around B<lists>. Each list can have zero or more |
50 |
|
B<members>. Each list can have zero or more B<messages>. |
51 |
|
|
52 |
|
Here comes a twist: each outgoing message will have unique e-mail generated, |
53 |
|
so Notice Sender will be able to link received replies (or bounces) with |
54 |
|
outgoing messages. |
55 |
|
|
56 |
|
It doesn't do much more than that. It B<can't> create MIME encoded e-mail, |
57 |
|
send attachments, handle 8-bit characters in headers (which have to be |
58 |
|
encoded) or anything else. |
59 |
|
|
60 |
|
It will just queue your e-mail message to particular list (sending it to |
61 |
|
possibly remote Notice Sender SOAP server just once), send it out at |
62 |
|
reasonable rate (so that it doesn't flood your e-mail infrastructure) and |
63 |
|
track replies. |
64 |
|
|
65 |
|
It is best used to send smaller number of messages to more-or-less fixed |
66 |
|
list of recipients while allowing individual responses to be examined. |
67 |
|
Tipical use include replacing php e-mail sending code with SOAP call to |
68 |
|
Notice Sender. It does support additional C<ext_id> field for each member |
69 |
|
which can be used to track some unique identifier from remote system for |
70 |
|
particular user. |
71 |
|
|
72 |
|
It comes with command-line utility C<sender.pl> which can be used to perform |
73 |
|
all available operation from scripts (see C<perldoc sender.pl>). |
74 |
|
This command is also useful for debugging while writing client SOAP |
75 |
|
application. |
76 |
|
|
77 |
=head1 METHODS |
=head1 METHODS |
78 |
|
|
131 |
|
|
132 |
Returns ID of newly created list. |
Returns ID of newly created list. |
133 |
|
|
134 |
Calls internally L<_add_list>, see details there. |
Calls internally C<_add_list>, see details there. |
135 |
|
|
136 |
=cut |
=cut |
137 |
|
|
235 |
} |
} |
236 |
|
|
237 |
If list is not found, returns false. If there is C<ext_id> in user data, |
If list is not found, returns false. If there is C<ext_id> in user data, |
238 |
that will also be returned. |
it will also be returned. |
239 |
|
|
240 |
=cut |
=cut |
241 |
|
|
284 |
|
|
285 |
Returns false if user doesn't exist. |
Returns false if user doesn't exist. |
286 |
|
|
287 |
|
This function will delete member from all lists (by cascading delete), so it |
288 |
|
shouldn't be used lightly. |
289 |
|
|
290 |
=cut |
=cut |
291 |
|
|
292 |
sub delete_member { |
sub delete_member { |
343 |
my $this_user = $user->search( email => $args->{'email'} )->first || croak "can't find user: ".$args->{'email'}; |
my $this_user = $user->search( email => $args->{'email'} )->first || croak "can't find user: ".$args->{'email'}; |
344 |
my $this_list = $list->search( name => $args->{'list'} )->first || croak "can't find list: ".$args->{'list'}; |
my $this_list = $list->search( name => $args->{'list'} )->first || croak "can't find list: ".$args->{'list'}; |
345 |
|
|
346 |
my $this_user_list = $user_list->search_where( list_id => $this_list->id, user_id => $this_list->id )->first || return; |
my $this_user_list = $user_list->search_where( list_id => $this_list->id, user_id => $this_user->id )->first || return; |
347 |
|
|
348 |
$this_user_list->delete || croak "can't delete user from list\n"; |
$this_user_list->delete || croak "can't delete user from list\n"; |
349 |
|
|
550 |
message => $message, |
message => $message, |
551 |
); |
); |
552 |
|
|
553 |
|
This method is used by C<sender.pl> when receiving e-mail messages. |
554 |
|
|
555 |
=cut |
=cut |
556 |
|
|
557 |
sub inbox_message { |
sub inbox_message { |
801 |
|
|
802 |
Returns array of hashes with user informations, see C<list_members>. |
Returns array of hashes with user informations, see C<list_members>. |
803 |
|
|
804 |
|
Returning arrays from SOAP calls is somewhat fuzzy (at least to me). It |
805 |
|
seems that SOAP::Lite client thinks that it has array with one element which |
806 |
|
is array of hashes with data. |
807 |
|
|
808 |
=cut |
=cut |
809 |
|
|
810 |
sub ListMembers { |
sub ListMembers { |
818 |
$list_name = $_[0]->{'list'}; |
$list_name = $_[0]->{'list'}; |
819 |
} |
} |
820 |
|
|
821 |
return $nos->list_members( list => $list_name ); |
return [ $nos->list_members( list => $list_name ) ]; |
822 |
|
} |
823 |
|
|
824 |
|
|
825 |
|
=head2 DeleteMemberFromList |
826 |
|
|
827 |
|
$member_id = DeleteMemberFromList( |
828 |
|
list => 'My list', |
829 |
|
email => 'e-mail@example.com', |
830 |
|
); |
831 |
|
|
832 |
|
=cut |
833 |
|
|
834 |
|
sub DeleteMemberFromList { |
835 |
|
my $self = shift; |
836 |
|
|
837 |
|
if ($_[0] !~ m/^HASH/) { |
838 |
|
return $nos->delete_member_from_list( |
839 |
|
list => $_[0], email => $_[1], |
840 |
|
); |
841 |
|
} else { |
842 |
|
return $nos->delete_member_from_list( %{ shift @_ } ); |
843 |
|
} |
844 |
} |
} |
845 |
|
|
846 |
|
|
847 |
=head2 AddMessageToList |
=head2 AddMessageToList |
848 |
|
|
849 |
$message_id = AddMessageToList( |
$message_id = AddMessageToList( |