1 # -*- Mode: perl; indent-tabs-mode: nil -*-
3 # The contents of this file are subject to the Mozilla Public
4 # License Version 1.1 (the "License"); you may not use this file
5 # except in compliance with the License. You may obtain a copy of
6 # the License at http://www.mozilla.org/MPL/
8 # Software distributed under the License is distributed on an "AS
9 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 # implied. See the License for the specific language governing
11 # rights and limitations under the License.
13 # The Original Code is the Bugzilla Bug Tracking System.
15 # The Initial Developer of the Original Code is Netscape Communications
16 # Corporation. Portions created by Netscape are
17 # Copyright (C) 1998 Netscape Communications Corporation. All
20 # Contributor(s): Harrison Page <harrison@netscape.com>
21 # Terry Weissman <terry@mozilla.org>
22 # Ian Hickson <mozbot@hixie.ch>
28 # User must declare the following package global variables:
29 # $Mails::owner = \'e-mail address of owner';
30 # $Mails::smtphost = 'name of SMTP server';
31 # $Mails::debug = \&function to print debug messages # better solutions welcome
33 # send mail to the owner
35 my ($subject, $text) = @_;
36 &$Mails::debug('I am going to mail the owner!!!');
37 return &sendmail($$Mails::owner, $0, $subject, $text);
41 # Returns today's date as an RFC822 compliant string with the
42 # exception that the year is returned as four digits. In my
43 # extremely valuable opinion RFC822 was wrong to specify the year
44 # as two digits. Many email systems generate four-digit years.
46 # Today is defined as the first parameter, if given, or else the
47 # value that time() gives.
49 my ($tsec,$tmin,$thour,$tmday,$tmon,$tyear,$twday,$tyday,$tisdst) = gmtime(shift || time());
50 $tyear += 1900; # as mentioned above, this is not RFC822 compliant, but is Y2K-safe.
51 $tsec = "0$tsec" if $tsec < 10;
52 $tmin = "0$tmin" if $tmin < 10;
53 $thour = "0$thour" if $thour < 10;
54 $tmon = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')[$tmon];
55 $twday = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')[$twday];
56 return "$twday, $tmday $tmon $tyear $thour:$tmin:$tsec GMT";
61 my ($to, $from, $subject, $text, $sig) = (@_, $0);
64 my $date = &RFC822time();
65 my $smtp = Net::SMTP->new($Mails::smtphost) or confess("Could not create SMTP connection to $Mails::smtphost! Giving Up");
66 $smtp->mail($ENV{USER}); # XXX ?
69 X-Mailer: $0, Mails.pm; $$Mails::owner
81 &$Mails::debug('Failed to send e-mail.');
83 &$Mails::debug('-'x40);
84 &$Mails::debug("To: $to");
85 &$Mails::debug("From: $from");
86 &$Mails::debug("Subject: $subject");
87 &$Mails::debug("\n$text\n-- \n$sig");
88 &$Mails::debug('-'x40);
95 ##########################################################
96 #### The Mails ##########################################
97 ##########################################################
100 my ($server, $port, $localAddr, $nick, $ircname, $username) = @_;
101 my $localAddrMessage;
102 if (defined($localAddr)) {
103 $localAddrMessage = <<end;
104 You've configured me to assume that '$localAddr' is the address of the
105 network interface to use. If this is wrong, change the localAddr
106 setting in the configuration file (or remove it to enable autodetect).
109 $localAddrMessage = <<end;
110 I'm currently autodetecting the address of the network interface to
111 use. If this host has more than one interface, set the localAddr
112 setting in the configuration file to the IP address of the outgoing
113 connection I should use.
116 return &mailowner("Help! I can't talk to $server:$port!", <<end);
120 I'm afraid I could not connect to the IRC server. I tried, and will
121 try and try again (unless you kill me...) but it was fruitless.
123 Could you kick the IRC server for me? Give it a right ol' booting.
124 And hit the network connection while you are at it, would you please?
128 Here is what I was trying to connect to:
146 return &mailowner("Woohoo! $server let me in!", <<end);
150 You'll be happy to know that everything turned out for the better.
157 my ($cfgfile, $hostname, $port, $username, $ircname, @nicks) = @_;
159 return &mailowner('There is a nick shortage!', <<end);
163 I could not find an unused nick on IRC.
165 I tried all of these:
168 If you like you could add some more nicks manually by
169 editing my configuration file, "$cfgfile"... *hint* *hint*
171 Here is what I think I am connected to:
178 I'll e-mail you again when I manage to get on.
186 return &mailowner("It's ok, I'm now using $nick as my nick.", <<end);
190 You'll be happy to know that everything turned out for the better.