aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Iurt/Mail.pm
diff options
context:
space:
mode:
authorGustavo De Nardin <spuk@mandriva.org>2007-05-12 20:11:53 +0000
committerGustavo De Nardin <spuk@mandriva.org>2007-05-12 20:11:53 +0000
commitc2801c794b9bcdcfecb9ce95bc1d449e6c58b128 (patch)
tree99140f43559dc34a3c95a58e7784325036edf26a /lib/Iurt/Mail.pm
parent9f069679e6b24ebe7409414a9ca2cc2e75fe05ea (diff)
downloadiurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar.gz
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar.bz2
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar.xz
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.zip
Restoring code lost in the SVN breakage from an old checkout
Diffstat (limited to 'lib/Iurt/Mail.pm')
-rw-r--r--lib/Iurt/Mail.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Iurt/Mail.pm b/lib/Iurt/Mail.pm
new file mode 100644
index 0000000..b805db2
--- /dev/null
+++ b/lib/Iurt/Mail.pm
@@ -0,0 +1,27 @@
+package Iurt::Mail;
+
+use strict;
+use MIME::Words qw(encode_mimewords);
+use base qw(Exporter);
+
+our @EXPORT = qw(
+ sendmail
+);
+
+sub sendmail {
+ my ($to, $cc, $subject, $text, $from, $debug) = @_;
+ do { print "Cannot find sender-email-address [$to]\n"; return } unless defined($to);
+ my $MAIL;
+ if (!$debug) { open $MAIL, "| /usr/sbin/sendmail -t" or return } else { open $MAIL, ">&STDOUT" or return }
+ my $sender = encode_mimewords($to);
+ $subject = encode_mimewords($subject);
+ print $MAIL "To: $sender\n";
+ if ($cc) { $cc = encode_mimewords($cc); print $MAIL "Cc: $cc\n" }
+ print $MAIL "From: $from\n";
+ print $MAIL "Subject: $subject\n";
+ print $MAIL "\n";
+ print $MAIL $text;
+ close($MAIL);
+}
+
+1