line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Birthday; |
2
|
|
|
|
|
|
|
our @EXPORT = qw/usage version send_mails verify_mails/;# Symbols to autoexport (:DEFAULT tag) |
3
|
1
|
|
|
1
|
|
22734
|
use base qw/Exporter/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
80
|
|
4
|
1
|
|
|
1
|
|
1356
|
use Mail::Sender; |
|
1
|
|
|
|
|
74674
|
|
|
1
|
|
|
|
|
782
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.4'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub send_mails { |
9
|
0
|
|
|
0
|
1
|
|
my ($name, $in_hr, $cfg_hr, $in_file) = @_; |
10
|
0
|
|
|
|
|
|
my @to = (); |
11
|
0
|
|
|
|
|
|
my $me = $$cfg_hr{maintainer}; |
12
|
0
|
|
|
|
|
|
my $subject = $in_file.' config file. You sent a birtday mail for: '; # subject only for maintainer |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# prepare sender - initiate transport parameters |
15
|
|
|
|
|
|
|
my $sender = new Mail::Sender{ |
16
|
|
|
|
|
|
|
smtp => $$cfg_hr{transport}{host}, |
17
|
|
|
|
|
|
|
port => $$cfg_hr{transport}{port}, |
18
|
|
|
|
|
|
|
from => $$cfg_hr{from} |
19
|
0
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# send E-Mail to all friends of birthday child |
22
|
0
|
0
|
|
|
|
|
if (${$$in_hr{$name}{friends}{names}}[0] == "others"){ |
|
0
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
push @to, $$in_hr{$_}{email}.',' for (grep { $_ ne $name } keys %$in_hr); # all - name |
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} else { |
25
|
0
|
|
|
|
|
|
push @to, $$in_hr{$_}{email}.',' for (@{$in_hr{$$in_hr{$name}{friends}{names}}}); |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if (@to) { |
29
|
|
|
|
|
|
|
$sender->MailMsg({ |
30
|
|
|
|
|
|
|
to => "@to", |
31
|
|
|
|
|
|
|
subject => $$in_hr{$name}{friends}{subject} |
32
|
0
|
|
|
|
|
|
}); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# congratulations E-Mail to birthday child |
36
|
|
|
|
|
|
|
$sender->MailMsg({ |
37
|
|
|
|
|
|
|
to => $$in_hr{$name}{email}, |
38
|
|
|
|
|
|
|
subject => $$in_hr{$name}{subject}, |
39
|
|
|
|
|
|
|
msg => $$in_hr{$name}{text} |
40
|
0
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# secret E-Mail only to me, as a reminder |
43
|
|
|
|
|
|
|
$sender->MailMsg({ |
44
|
|
|
|
|
|
|
to => $me, |
45
|
|
|
|
|
|
|
subject => $subject.$$in_hr{$name}{email}, |
46
|
|
|
|
|
|
|
msg => $$in_hr{$name}{text} |
47
|
0
|
|
|
|
|
|
}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub verify_mails { |
51
|
0
|
|
|
0
|
1
|
|
my ($name, $in_hr, $cfg_hr, $in_file) = @_; |
52
|
0
|
|
|
|
|
|
my @to = (); |
53
|
0
|
|
|
|
|
|
my $me = $$cfg_hr{maintainer}; |
54
|
0
|
|
|
|
|
|
my $subject = $in_file.' config file. You sent a birtday mail for: '; # subject only for maintainer |
55
|
|
|
|
|
|
|
# send E-Mail to all friends of birthday child |
56
|
0
|
0
|
|
|
|
|
if (${$$in_hr{$name}{friends}{names}}[0] == "others"){ |
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
push @to, $$in_hr{$_}{email}.',' for (grep { $_ ne $name } keys %$in_hr); # all - name |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
|
push @to, $$in_hr{$_}{email}.',' for (@{$in_hr{$$in_hr{$name}{friends}{names}}}); |
|
0
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
print "[*] Configuration:\n"; |
63
|
0
|
|
|
|
|
|
printf "\t [-] smtp: %s\n", $$cfg_hr{transport}{host}; |
64
|
0
|
|
|
|
|
|
printf "\t [-] port: %s\n", $$cfg_hr{transport}{port}; |
65
|
0
|
|
|
|
|
|
printf "\t [-] from: %s\n", $$cfg_hr{from}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
print "[*] Mail to birthday child:\n"; |
68
|
0
|
|
|
|
|
|
printf "\t [-] to: %s\n", $$in_hr{$name}{email}; |
69
|
0
|
|
|
|
|
|
printf "\t [-] subject: %s\n", $$in_hr{$name}{subject}; |
70
|
0
|
|
|
|
|
|
printf "\t [-] msg: %s\n", $$in_hr{$name}{text}; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
print "[*] Mail to friends:\n"; |
73
|
0
|
|
|
|
|
|
printf "\t [-] to: %s\n", "@to"; |
74
|
0
|
|
|
|
|
|
printf "\t [-] subject: %s\n", $$in_hr{$name}{friends}{subject}; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
print "[*] Reminder Mail to me:\n"; |
77
|
0
|
|
|
|
|
|
printf "\t [-] to: %s\n", $me; |
78
|
0
|
|
|
|
|
|
printf "\t [-] subject: %s\n", $subject.$$in_hr{$name}{email}; |
79
|
0
|
|
|
|
|
|
printf "\t [-] msg: %s\n", $$in_hr{$name}{text}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
0
|
1
|
|
sub usage { system("perldoc $0"); exit 0; } |
|
0
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
1
|
|
sub version { print "Version: $VERSION\n"; exit 0; } |
|
0
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; # End of App::Birthday |
85
|
|
|
|
|
|
|
__END__ |