Hi,
With the help of one of the other posters to this site, I have come up with the following perl script which I run under cron. It checks a directory on my webserver, and if a report has been uploaded to the directory it moves it to a public area of the webserver and issues an email notification...
#!/usr/bin/perl
### Load copy module
use File::Copy;
### Define e-mail sender and e-mail recipient
my $email_sender = "sender/@test.com";
my $email_recipient1 = "testaddress1/@test.com";
my $email_recipient2 = "testaddress1/@test.com";
### Define home directory where file will be uploaded
my $home_dir = "/home/isabelle/Webupdate/reports/inventory";
### Open home directory for reading
opendir (HOME_DIR, $home_dir) or die "Problem opening directory $home_dir: $!";
### Load files that end in ".html" and ".txt" only into @home_dir_array array
my @home_dir_array = grep( /.html$/ || /.doc$/ || /.xls$/ || /.txt$/ , readdir(HOME_DIR));
### Load files that end in ".txt" only into @home_dir_array array
#my @home_dir_array = grep( /.txt$/ , readdir(HOME_DIR));
### Load files that end in ".html", ".txt" and ".doc" into @home_dir_array array
#my @home_dir_array = grep( /.html$/ || /.txt$/ || /.xls$/ || /.doc$/ , readdir(HOME_DIR));
### Close directory handle
closedir (HOME_DIR);
### Begin loop that will send one e-mail for every file matching "html" and "txt"
foreach my $file(@home_dir_array) {
chomp $file; #Remove trailing newline character
print "Found File: $file\n";
`mutt -x -s "File Uploaded to the Website: $file" $email_recipient1 < /dev/null`;
`mutt -x -s "File Uploaded to the Website: $file" $email_recipient2 < /dev/null`;
### Copy file to new webserver directory or print error message if problem
move("$home_dir/$file", "/home/httpd/reports/dir567/reports/Inventory/$file") or print "Problem copying $file to /home/httpd/reports.dpt-ltd.co.uk/hp567/reports/Inventory/$file $? $!\n";
}
This all works fine, however my problem is as follows. When the notification email is sent out, the sender address appears to be
root@www.dpt-private.net and I'm told that most mail servers will not accept mail from "unofficial" internet hosts like this whose IP address and hostname are not ratified. Is this correct? This basically means that I can't send my email notification to anyone outwith my own intranet, which obviously isn't much good.
So my question is this - how can I modify my script to make the sender's email address appear to be something different???
Any advice will be gratefully received!
James