]> mj.ucw.cz Git - pciids.git/blob - PciIds/Email.pm
Remove useless directories
[pciids.git] / PciIds / Email.pm
1 package PciIds::Email;
2 use strict;
3 use warnings;
4 use PciIds::Config;
5 use base 'Exporter';
6
7 our @EXPORT = qw(&sendMail);
8
9 checkConf( [ 'from_addr', 'sendmail' ] );
10 defConf( { 'sendmail' => '/usr/sbin/sendmail' } );
11
12 sub sendMail( $$$ ) {
13         my( $to, $subject, $body ) = @_;
14         my( $from, $sendmail ) = confList( [ 'from_addr', 'sendmail' ] );
15         $body =~ s/^\.$/../gm;
16         open SENDMAIL, "|$sendmail -f$from $to" or die 'Can not send mail';
17         print SENDMAIL "From: $from\n".
18                 "To: $to\n".
19                 "Subject: $subject\n".
20                 "Content-Type: text/plain; charset=\"utf8\"\n".
21                 "\n".
22                 $body."\n.\n";
23         close SENDMAIL or die "Sending mail failed: $!, $?";
24 }
25
26 1;