source: soft/build_system/build_system/iurt/trunk/lib/Iurt/Mail.pm @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 705 bytes
Line 
1package Iurt::Mail;
2
3use strict;
4use MIME::Words qw(encode_mimewords);
5use base qw(Exporter);
6
7our @EXPORT = qw(
8    sendmail
9);
10
11sub sendmail {
12        my ($to, $cc, $subject, $text, $from, $debug) = @_;
13        do { print "Cannot find sender-email-address [$to]\n"; return } unless defined($to);
14        my $MAIL;
15        if (!$debug) { open $MAIL,  "| /usr/sbin/sendmail -t" or return } else { open $MAIL,  ">&STDOUT" or return }
16        my $sender = encode_mimewords($to);
17        $subject = encode_mimewords($subject);
18        print $MAIL "To: $sender\n";
19        if ($cc) { $cc = encode_mimewords($cc); print $MAIL "Cc: $cc\n" }
20        print $MAIL "From: $from\n";
21        print $MAIL "Subject: $subject\n";
22        print $MAIL "\n";
23        print $MAIL $text; 
24        close($MAIL);
25}
26
271
Note: See TracBrowser for help on using the repository browser.