PDA

View Full Version : Using Mail Processor to send email notification


Mandler
01-05-2008, 10:44 PM
I want to use a mail processor script as a way to notify someone (via a different email address of theirs) that they have email waiting. Is this possible?

I pasted together a PERL script (using a couple of examples from Sheila) attached to the end of this message, placed it my big/dom/xdomain directory, set permissions to 0755, and used CNC to specify a processor that pointed to the file's path.

When I send email to the account, the email is properly received but the intended notification isn't generated. There are no errors in the logs.

Thanks... alan


- - -

#!/usr/bin/perl
while (<STDIN>) { print; }
open (SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") or die "Can't fork for sendmail: $!\n";
print SENDMAIL <<"EOF";

From: "Mail Server" <AccountName\@DomainName.com>
To: "Recipient Name" <Recipient\@gmail.com>
Subject: You have email waiting.

A message is waiting in your Polo Info email account.
EOF

close(SENDMAIL) or warn "sendmail didn't close nicely";

Slim
01-05-2008, 11:40 PM
I pasted together a PERL script (using a couple of examples from Sheila) attached to the end of this message, placed it my big/dom/xdomain directory, set permissions to 0755, and used CNC to specify a processor that pointed to the file's path.

I'm not sure what you mean be "used CNC to specify a processor." Are you attaching some sort of filter that acts to run the perl script?

When I send email to the account, the email is properly received but the intended notification isn't generated. There are no errors in the logs. Have you tried running the script from the command line and seeing if it generates the mail?

Mandler
01-06-2008, 12:13 AM
Hi Slim,

Yes on the filter. I set up a custom filter, set to Processor, and referenced the PERL file.

Great idea on the command line. I had never used it before and just learned how to access it via CNC.

Created an identical test file without "while (<STDIN>) { print; }" and ran it. No errors. No email. I guess something is wrong with the program but I don't know enough about PERL to figure it out.

Thanks for your suggestion. I appreciate it.

... alan

Mandler
01-06-2008, 02:11 AM
Got it to work with a new script.

#!/usr/bin/perl

while (<STDIN>) { print; }

unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.\n";
warn "Error starting sendmail: $!";
}

else{
print MAIL "From: sender\@my_domain.com\n";
print MAIL "To: recipient\@my_domain.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "test mail message";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";
}

Bruce
01-06-2008, 11:16 PM
Got it to work with a new script.

while (<STDIN>) { print; }If this is all you are doing to process the email, what you probably want to do instead is to set it up as a "Simple Filter" instead and drop this while/print loop. A "processor" is intended for scripts that will actually modify the message before it is saved in the mailbox.