merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / modules / installer / mail.pm
blobec71a8c4483f42715d7899099ec5aa1037bcb53b
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: mail.pm,v $
11 # $Revision: 1.10 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::mail;
34 use Net::SMTP;
35 use installer::converter;
36 use installer::exiter;
37 use installer::ziplist;
39 #########################################
40 # Sending a mail
41 #########################################
43 sub send_mail
45 my ($message, $listenerstring, $mailinfostring, $languagesref, $destdir) = @_;
47 my $listener = installer::converter::convert_stringlist_into_array($listenerstring, ",");
48 my $mailinfo = installer::converter::convert_stringlist_into_array($mailinfostring, ",");
50 my @listener = ();
52 for ( my $i = 0; $i <= $#{$listener}; $i++ ) { push(@listener, ${$listener}[$i]); }
53 for ( my $i = 0; $i <= $#{$mailinfo}; $i++ ) { ${$mailinfo}[$i] =~ s/\s*$//g; }
55 my $smtphost = ${$mailinfo}[0];
56 my $account = ${$mailinfo}[1];
57 my $sender = ${$mailinfo}[2];
59 if ( ! $smtphost ) { installer::exiter::exit_program("ERROR: Could not read SMTP Host in list file!", "send_mail"); }
60 if ( ! $account ) { installer::exiter::exit_program("ERROR: Could not read Account in list file!", "send_mail"); }
61 if ( ! $sender ) { installer::exiter::exit_program("ERROR: Could not read Sender in list file!", "send_mail"); }
63 my $subject = "";
64 my $basestring = $installer::globals::product . " " . $installer::globals::compiler . $installer::globals::productextension . " " . $installer::globals::build. " " . $installer::globals::buildid . " " . $$languagesref . "\n";
65 if ( $message eq "ERROR" ) { $subject = "ERROR: $basestring" }
66 if ( $message eq "SUCCESS" ) { $subject = "SUCCESS: $basestring" }
68 my @message = ();
70 my $recipient_string = join ',', @listener;
71 push(@message, "Subject: $subject");
72 push(@message, "To: $recipient_string");
73 push(@message, "\n");
74 push(@message, "Located at $destdir");
76 if ( $message eq "ERROR" )
78 for ( my $j = 0; $j <= $#installer::globals::errorlogfileinfo; $j++ )
80 my $line = $installer::globals::errorlogfileinfo[$j];
81 $line =~ s/\s*$//g;
82 push(@message, $line);
86 for ( my $i = 0; $i <= $#message; $i++ ) { $message[$i] = $message[$i] . "\015\012"; }
88 my $smtp = Net::SMTP->new( $smtphost, Hello => $account, Debug => 0 );
90 # set sender
91 $smtp->mail($sender);
93 # listener
94 my @good_addresses = ();
95 $smtp->recipient( @listener, { SkipBad => 1 } );
97 # send message
98 $smtp->data(\@message);
100 # quit server
101 $smtp->quit();
104 sub send_fail_mail
106 my ($allsettingsarrayref, $languagestringref, $errordir) = @_;
108 # sending a mail into the error board
109 my $listener = "";
110 $listener = installer::ziplist::getinfofromziplist($allsettingsarrayref, "fail");
112 if ( $$listener )
114 my $mailinfo = installer::ziplist::getinfofromziplist($allsettingsarrayref, "mailinfo");
116 if ( $$mailinfo ) { send_mail("ERROR", $listener, $mailinfo, $languagestringref, $errordir); }
117 else { installer::exiter::exit_program("ERROR: Could not read mailinfo in list file!", "send_fail_mail"); }
121 sub send_success_mail
123 my ($allsettingsarrayref, $languagestringref, $completeshipinstalldir) = @_;
125 # sending success mail
126 my $listener = "";
127 $listener = installer::ziplist::getinfofromziplist($allsettingsarrayref, "success");
129 if ( $$listener )
131 my $mailinfo = installer::ziplist::getinfofromziplist($allsettingsarrayref, "mailinfo");
133 if ( $$mailinfo ) { send_mail("SUCCESS", $listener, $mailinfo, $languagestringref, $completeshipinstalldir); }
134 else { installer::exiter::exit_program("ERROR: Could not read mailinfo in list file!", "send_success_mail"); }