Skip to content

Commit a54bc8f

Browse files
committed
Implement rate limit for sending e-mails
1 parent 904922a commit a54bc8f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/VWF/Display/index.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ sub html {
103103
die 'No email entry assigned to ', $info->person();
104104
}
105105

106+
# Rate limit for sending e-mails
107+
if(my $remote_addr = $ENV{'REMOTE_ADDR'}) {
108+
if($self->{'mailfrom'}->{$remote_addr} >= 2) {
109+
$self->{_logger}->info("E-mail blocked to $to");
110+
return $self->SUPER::html({ error => 'You have reached your limit for sendmail e-mails' });
111+
}
112+
$self->{'mailfrom'}->{$remote_addr}++;
113+
}
114+
106115
# Send the email
107116
if(open(my $fout, '|-', '/usr/sbin/sendmail -t')) {
108117
print $fout "To: $to\n",

0 commit comments

Comments
 (0)