| 1 | # | ||||||||||||||||||||
| 2 | # Mail/Salsa/Action/Subscribe.pm | ||||||||||||||||||||
| 3 | # Last Modification: Thu Jul 1 12:02:05 WEST 2004 | ||||||||||||||||||||
| 4 | # | ||||||||||||||||||||
| 5 | # Copyright (c) 2004 Henrique Dias <hdias@aesbuc.pt>. All rights reserved. | ||||||||||||||||||||
| 6 | # This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 7 | # it under the same terms as Perl itself. | ||||||||||||||||||||
| 8 | # | ||||||||||||||||||||
| 9 | package Mail::Salsa::Action::Subscribe; | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | ▶ | use 5.008000; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | require Exporter; | |||||||||||||||||||
| 16 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 1 | ▶ | use Mail::Salsa::Logs qw(logs); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | use Mail::Salsa::Utils qw(file_path); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||
| 23 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||
| 24 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | # This allows declaration use Mail::Salsa ':all'; | ||||||||||||||||||||
| 27 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||
| 28 | # will save memory. | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw() ] ); | |||||||||||||||||||
| 31 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||
| 32 | 1 | our @EXPORT = qw(); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 37 | 0 | my $proto = shift; | |||||||||||||||||||
| 38 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 39 | 0 | my $self = {@_}; | |||||||||||||||||||
| 40 | 0 | bless ($self, $class); | |||||||||||||||||||
| 41 | 0 | $self->process_msg(); | |||||||||||||||||||
| 42 | 0 | return($self); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | ▶ | sub process_msg { | ||||||||||||||||||
|
Subroutine
process_msg: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 46 | 0 | my $self = shift; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | my ($name, $domain) = split(/\@/, $self->{'list'}); | |||||||||||||||||||
| 49 | 0 | ▶ | if($self->{'config'}->{'subscribe'} eq "n") { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||
| 51 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||
| 52 | timeout => $self->{'timeout'}, | ||||||||||||||||||||
| 53 | label => "SUBSCRIBE", | ||||||||||||||||||||
| 54 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||
| 55 | vars => { | ||||||||||||||||||||
| 56 | from => "$name\-owner\@$domain", | ||||||||||||||||||||
| 57 | to => $self->{'from'}, | ||||||||||||||||||||
| 58 | 0 | list => $self->{'list'}, | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||
| 61 | 0 | return(); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | 0 | my $file = file_path($self->{'list'}, $self->{'list_dir'}, "list\.txt"); | |||||||||||||||||||
| 64 | 0 | my @emails = (); | |||||||||||||||||||
| 65 | 0 | ▶ | if(exists($self->{'headers'}->{'0.0'}->{'cc'})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | 0 | @emails = split(/ *[\,\;] */, $self->{'headers'}->{'0.0'}->{'cc'}); | |||||||||||||||||||
| 67 | 0 | Mail::Salsa::Utils::only_addresses(\@emails); | |||||||||||||||||||
| 68 | 0 | } else { $emails[0] = $self->{'from'}; } | |||||||||||||||||||
| 69 | 0 | my $exist = Mail::Salsa::Utils::check4email(\@emails, $file); | |||||||||||||||||||
| 70 | 0 | ▶ | if(my $n = scalar(@{$exist})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||
| 72 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||
| 73 | timeout => $self->{'timeout'}, | ||||||||||||||||||||
| 74 | label => "EMAIL_EXISTS", | ||||||||||||||||||||
| 75 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||
| 76 | vars => { | ||||||||||||||||||||
| 77 | from => "$name\-owner\@$domain", | ||||||||||||||||||||
| 78 | to => $self->{'from'}, | ||||||||||||||||||||
| 79 | list => $self->{'list'}, | ||||||||||||||||||||
| 80 | 0 | emails => join("\n", @{$exist}), | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||
| 83 | 0 | ▶ | ($n < scalar(@emails)) or return(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | 0 | my $kfile = file_path($self->{'list'}, $self->{'list_dir'}, 'stamp.txt'); | |||||||||||||||||||
| 86 | 0 | ▶ | if(my $stamp = Mail::Salsa::Utils::get_key($kfile)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | 0 | ▶ | if(my $human = Mail::Salsa::Utils::lookup4key($self->{'message'}, $stamp)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 0 | $self->add2list(); | |||||||||||||||||||
| 89 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||
| 90 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||
| 91 | timeout => $self->{'timeout'}, | ||||||||||||||||||||
| 92 | label => "EMAIL_ADDED", | ||||||||||||||||||||
| 93 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||
| 94 | vars => { | ||||||||||||||||||||
| 95 | from => "$name\-owner\@$domain", | ||||||||||||||||||||
| 96 | to => $self->{'from'}, | ||||||||||||||||||||
| 97 | 0 | list => $self->{'list'}, | |||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||
| 100 | } else { | ||||||||||||||||||||
| 101 | 0 | for my $email (@emails) { | |||||||||||||||||||
| 102 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||
| 103 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||
| 104 | timeout => $self->{'timeout'}, | ||||||||||||||||||||
| 105 | label => "CONFIRM_SUB", | ||||||||||||||||||||
| 106 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||
| 107 | vars => { | ||||||||||||||||||||
| 108 | from => "$name\-subscribe\@$domain", | ||||||||||||||||||||
| 109 | to => $email, | ||||||||||||||||||||
| 110 | list => $self->{'list'}, | ||||||||||||||||||||
| 111 | stamp => $stamp, | ||||||||||||||||||||
| 112 | 0 | origin => $self->{'from'}, | |||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||
| 115 | } | ||||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | 0 | return(); | |||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 0 | ▶ | sub add2list { | ||||||||||||||||||
|
Subroutine
add2list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 0 | my $file = file_path($self->{'list'}, $self->{'list_dir'}, "list\.txt"); | |||||||||||||||||||
| 125 | 0 | ▶ | open(LIST, ">>", $file) or die("$!"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 126 | 0 | print LIST $self->{'from'}, "\n"; | |||||||||||||||||||
| 127 | 0 | close(LIST); | |||||||||||||||||||
| 128 | 0 | return(); | |||||||||||||||||||
| 129 | } | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | 1 | 1; | |||||||||||||||||||
| 134 | __END__ | ||||||||||||||||||||