From accaa3d02049d5399e50839ea0951b2b5f97d5a1 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 18 Jun 2002 17:20:34 +0000 Subject: Build mail a bit different --- Echolot/Tools.pm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'Echolot') diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 2c82ac7..448b198 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -1,7 +1,7 @@ package Echolot::Tools; # (c) 2002 Peter Palfrader -# $Id: Tools.pm,v 1.2 2002/06/11 09:54:17 weasel Exp $ +# $Id: Tools.pm,v 1.3 2002/06/18 17:20:34 weasel Exp $ # =pod @@ -110,7 +110,6 @@ sub send_message(%) { if (defined $args{'Token'}) { $args{'From'} = make_address( $args{'Token'} ); } else { - cluck ("Sending messages without tokens?"); $args{'From'} = Echolot::Config::get()->{'my_localpart'}. '@'. @@ -118,13 +117,15 @@ sub send_message(%) { }; $args{'Subject'} = 'none' unless (defined $args{'Subject'}); - my $message = "To: $args{'To'}\n"; - $message .= "From: $args{'From'}\n"; - $message .= "Subject: $args{'Subject'}\n"; - $message .= "\n".$args{'Body'}; - - my @lines = split (/\n/, $message); - my $mail = new Mail::Internet ( \@lines ); + my $head = new Mail::Header; + $head->add ( 'To', $args{'To'} ); + $head->add ( 'From', $args{'From'} ); + $head->add ( 'Subject', $args{'Subject'} ); + + my @lines = map { $_."\n" } split (/\r?\n/, $args{'Body'}); + my $mail = new Mail::Internet ( + Header => $head, + Body => \@lines ); $mail->smtpsend( Host => Echolot::Config::get()->{'smarthost'} ); }; -- cgit v1.2.3