I'm trying some sort of auto-subscription via a homegrown script. I know it can be achieved by mailing lists such as Mailman but I also want to learn at the same time on how to do it by hand.
Here's the simple script:
#!/usr/bin/perl
use strict;
use warnings;
open ("RCV_MAIL", ">>/home/icasimpan/mail_received.txt") or die $!;
while(<STDIN>){
print RCV_MAIL;
}
close(RCV_MAIL);
I attached the above script in /etc/aliases using the syntax:
subscribe: | /home/icasimpan/parse-subscribe.pl
and run
$ sudo newaliases
It's still a very bare script. Just testing out if I my syntax in /etc/aliases is correct.
But when I tried emailing subscribe@mydomaintests.tld, it returns something like:
Delivery failure 69
I'm using Lotus Notes so my google search directed me to this link. Apparently, something to do with the file…Not sure.
The command is executable, in fact I tried making it 777 and even created the mail_received.txt in the directory just to ensure I have no file permission problem but still the same.
Best Answer
If you're running a sendmail with smrsh set up (common in a lot of default configurations) you will need to run the piped command out of /etc/smrsh/. It can either be a symlink or a copy of the script, but if sendmail has 'smrsh' defined, it will need to be run from that directory. For example:
Check the sendmail documentation on smrsh for more details.