X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FMailer%2FSMTP.pm;h=831bd72b43a096d1cede01c2904bd492c537a3a3;hb=297ec9f0dcfb45a3d695506c824f13fd72f7d312;hp=e2eff6857e9136819e089163632b3367a64cf1cd;hpb=5896d8bf4393add9948ca688ae0ed7c75c04a287;p=kivitendo-erp.git diff --git a/SL/Mailer/SMTP.pm b/SL/Mailer/SMTP.pm index e2eff6857..831bd72b4 100644 --- a/SL/Mailer/SMTP.pm +++ b/SL/Mailer/SMTP.pm @@ -49,7 +49,26 @@ sub start_mail { sub print { my $self = shift; - $self->{smtp}->datasend(@_); + # SMTP requires at most 1000 characters per line. Each line must be + # terminated with , meaning \r\n in Perl. + + # First, normalize the string by removing all \r in order to fix + # possible wrong combinations like \n\r. + my $str = join '', @_; + $str =~ s/\r//g; + + # Now remove the very last newline so that we don't create a + # superfluous empty line at the very end. + $str =~ s/\n$//; + + # Split the string on newlines keeping trailing empty parts. This is + # requires so that input like "Content-Disposition: ..... \n\n" is + # treated correctly. That's also why we had to remove the very last + # \n in the prior step. + my @lines = split /\n/, $str, -1; + + # Send each line terminating it with \r\n. + $self->{smtp}->datasend("$_\r\n") for @lines; } sub send {