Greetings everyone,
I have gotten a little stumped as I am not too familiar with Postfix. I took a perl script from a recent issue of 2600 magazine. (Vol20, #2) It was designed for IIS 5, but I wanted the mailing part of it for my own script.
Here is my scenario. The script creates a .TXT file in the outgoing mail queue directory. I assume that from there it gets sent out. My problem is that I don't know where to set the path of that mail queue.
As the script is not long, I will put it up here, and any suggestions would be great!
Code:
#!/usr/bin/perl5.8.1
# Modification of Watcher.cgi from 2600 - Vol 20, 2
$recipient = "admin\@mynetwork.com";
@cclist = ("me\@mynetworks.com");
#$smtp_server_name = "localhost";
$smtp_pickup_path = "\/var\/spool\/mail\/";
#&getIP;
&getDateTime;
&writeMail;
sub getDateTime {
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime((time-18000));
my $ampm;
my $hrformat;
$year = 1900 + $year;
if ($min < 10) { $min = " 0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
if ($hour < 12) { $ampm = "am"; } else { $ampm = "pm"; }
if ($hour > 12) { $hour = ($hour - "12");}
if ($hour eq "0") { $hour = "12";}
$datetime = ($mon + 1) . "\/$mday\/$year at $hour:$min $ampm EST";
}
# The next line is to test the getDateTime function
print "$datetime\n";
sub writeMail {
my $server_name = lc($ENV{'COMPUTERNAME'});
my $from_name = "$server_name M3IP";
my $from_email = "$server_name\@x12networks.com";
my $subject = "Updated IP";
$tempfile = "m3ip\-out";
open TMP, ">>$smtp_pickup_path$tempfile" or die;
print TMP "x-sender: $from_email\n";
print TMP "x-receiver: $recipient\n";
if (@cclist) {
foreach my $ccaddress (@cclist) {
print TMP "x-receiver: $ccaddress\n"; }
}
print TMP "To: $recipient\n";
print TMP "CC: @cclist\n";
print TMP "From: $from_name <$from_email>\n";
print TMP "Subject: $subject\n";
print TMP "\r\n";
print TMP "This is the body of the email.\n";
print TMP "It was sent on: $datetime\n";
print TMP "\r\n";
close TMP;
}
I made the line I am confused about bold. Not sure if anyone has suggestions, as I am new to Perl too. I also changed the addresses that are used up there, obviously.
Also, if anyone has suggestions, please feel free to jump in here.