1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: mail.pm,v $
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
;
35 use installer
::converter
;
36 use installer
::exiter
;
37 use installer
::ziplist
;
39 #########################################
41 #########################################
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, ",");
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"); }
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" }
70 my $recipient_string = join ',', @listener;
71 push(@message, "Subject: $subject");
72 push(@message, "To: $recipient_string");
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];
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 );
94 my @good_addresses = ();
95 $smtp->recipient( @listener, { SkipBad
=> 1 } );
98 $smtp->data(\
@message);
106 my ($allsettingsarrayref, $languagestringref, $errordir) = @_;
108 # sending a mail into the error board
110 $listener = installer
::ziplist
::getinfofromziplist
($allsettingsarrayref, "fail");
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
127 $listener = installer
::ziplist
::getinfofromziplist
($allsettingsarrayref, "success");
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"); }