| 1 | package App::Birthday; | ||||||||||
| 2 | 2 | our @EXPORT = qw/usage version send_mails verify_mails/;# Symbols to autoexport (:DEFAULT tag) | |||||||||
| 3 | 2 | ▶ | use base qw/Exporter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use Mail::Sender; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | our $VERSION = '0.4'; | |||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | sub send_mails { | ||||||||
|
Subroutine
send_mails: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 9 | 0 | 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 | ▶ | if (${$$in_hr{$name}{friends}{names}}[0] == "others"){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | push @to, $$in_hr{$_}{email}.',' for (grep { $_ ne $name } keys %$in_hr); # all - name | |||||||||
| 24 | } else { | ||||||||||
| 25 | 0 | push @to, $$in_hr{$_}{email}.',' for (@{$in_hr{$$in_hr{$name}{friends}{names}}}); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | if (@to) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | ▶ | sub verify_mails { | ||||||||
|
Subroutine
verify_mails: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 51 | 0 | 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 | ▶ | if (${$$in_hr{$name}{friends}{names}}[0] == "others"){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | push @to, $$in_hr{$_}{email}.',' for (grep { $_ ne $name } keys %$in_hr); # all - name | |||||||||
| 58 | } else { | ||||||||||
| 59 | 0 | push @to, $$in_hr{$_}{email}.',' for (@{$in_hr{$$in_hr{$name}{friends}{names}}}); | |||||||||
| 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 | ▶ | sub usage { system("perldoc $0"); exit 0; } | ||||||||
|
Subroutine
usage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 83 | 0 | ▶ | sub version { print "Version: $VERSION\n"; exit 0; } | ||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 84 | 2 | 1; # End of App::Birthday | |||||||||
| 85 | __END__ | ||||||||||