Pm/Email.pm
59 lines of code
1
package Email;
2
3
#/
4
# A package to send email messages
5
#/
6
7
use strict;
8
use warnings;
9
use CGI::Carp qw(fatalsToBrowser);
10
use Exporter;
11
use vars qw($VERSION @ISA @EXPORT_OK);
12
use CGI;
13
14
$VERSION     = 1.00;
15
@ISA         = qw(Exporter);
16
@EXPORT_OK   = qw(
17
                  email_send
18
                 );
19
20
##########################
21
22
use lib "./Pm";
23
24
##########################
25
26
my $TABLE_BORDER = 0;
27
my $DEBUG = 0;
28
29
our $WELCOME_MSG = "";
30
our $PASSWORD_RESET_MSG = "";
31
our $EMAIL_CHANGE_MSG = "";
32
33
##########################
34
35
my $HEADER_MSG = "Greetings, from Night-Stand.ca\n\n";
36
37
my $FOOTER_MSG = "https://night-stand.ca/\n";
38
$FOOTER_MSG .= "A division of aTad nMad Web Design, Ltd\n";
39
40
##########################
41
42
sub email_send($$$;$) {
43
  #*
44
  # sends an email
45
  #*
46
  my ($e, $subj, $msg, $reply) = @_; # an email address && a subject && a message && reply-to
47
  if (not $reply) { $reply = 'noreply@night-stand.ca'; }
48
  
49
  # $msg needs to be "sanitized", because we are not smart at this!
50
  $msg = $HEADER_MSG . $msg . $FOOTER_MSG;
51
  
52
  my $command = 'echo "' . $msg . '" | mail -s "' . $subj . '" -r "' . $reply . '" -- "' . $e . '"';
53
  `$command`;
54
55
  return 1; # a return value of 1 (aka true)
56
  #usage: email_send($email, $subj, $msg, 'abuse@night-stand.ca');
57
}
58
59
1;