Below is the routine to test different possible locations of sendmail. The first is what my host recommends as an alternative, but the old sendmail is still usable. The routine detects and sets variable to /usr/lib/sendmail -t -oeq, however when it gets to html_email (copied at end of this message), I get cgi error "unable to open mail program". Is there something wrong with the html_email routine? Help!
Oh yes, putting the "|" in front of the url makes the test routine not find the sendmail program.
#---------------------------------------------------------
# Always returns location as "/usr/lib/sendmail -t -oeq"
$flags = "-t -oeq";
# The following code checks for versions of sendmail and lets the user know if one of the
# default locations does not exist.
$mailer = '/usr/sbin/exim_nproc -t -oeq';
$mailer1 = '/usr/lib/sendmail';
$mailer2 = '/usr/bin/sendmail';
$mailer3 = '/usr/sbin/sendmail';
if ( -e $mailer) {
$mailprog=$mailer;
} elsif( -e $mailer1){
$mailprog=$mailer1;
} elsif( -e $mailer2){
$mailprog=$mailer2;
} elsif( -e $mailer3){
$mailprog=$mailer3;
} else {
print "Content-type: text/html\n\n";
print "I can't find sendmail, shutting down...<br>";
print "Whoever set this machine up put it someplace weird.";
exit;
}
# Add the command line flags
$mailprog = "$mailprog $flags ";
$admin_email = 'blah@blah.com';
$admin_name = 'DBSPEC Administrator';
---------------------------------------------------------------------- html_email routine in html.pl
sub html_email {
%rec = &get_record($in{$db_key});
# the email address of the one who owns the record. Set to -1 if not used.
$db_email_field = $rec{'Name'};
# Send email to admin
open (MAIL, '$mailprog') or &cgierr('unable to open mail program');
print MAIL 'To: $admin_email\n';
print MAIL 'From: $admin_email\n';
print MAIL 'Subject: DBSPEC New Record Added\n';
print MAIL '-' x 75 . '\n\n';
foreach $column(@db_cols) {
print MAIL '$column: $rec{$column}\n';
}
close MAIL;
# send mail to user
open (MAIL, '$mailprog') or &cgierr('unable to open mail program');
print MAIL "To: $rec{'Email'}\n";
print MAIL 'From: $admin_email\n';
print MAIL 'Subject: DBSPEC New Record Added\n';
print MAIL '-' x 75 . '\n\n';
foreach $column(@db_cols) {
print MAIL '$column: $rec{$column}\n';
}
close MAIL;
}
Regards,
John
Oh yes, putting the "|" in front of the url makes the test routine not find the sendmail program.
#---------------------------------------------------------
# Always returns location as "/usr/lib/sendmail -t -oeq"
$flags = "-t -oeq";
# The following code checks for versions of sendmail and lets the user know if one of the
# default locations does not exist.
$mailer = '/usr/sbin/exim_nproc -t -oeq';
$mailer1 = '/usr/lib/sendmail';
$mailer2 = '/usr/bin/sendmail';
$mailer3 = '/usr/sbin/sendmail';
if ( -e $mailer) {
$mailprog=$mailer;
} elsif( -e $mailer1){
$mailprog=$mailer1;
} elsif( -e $mailer2){
$mailprog=$mailer2;
} elsif( -e $mailer3){
$mailprog=$mailer3;
} else {
print "Content-type: text/html\n\n";
print "I can't find sendmail, shutting down...<br>";
print "Whoever set this machine up put it someplace weird.";
exit;
}
# Add the command line flags
$mailprog = "$mailprog $flags ";
$admin_email = 'blah@blah.com';
$admin_name = 'DBSPEC Administrator';
---------------------------------------------------------------------- html_email routine in html.pl
sub html_email {
%rec = &get_record($in{$db_key});
# the email address of the one who owns the record. Set to -1 if not used.
$db_email_field = $rec{'Name'};
# Send email to admin
open (MAIL, '$mailprog') or &cgierr('unable to open mail program');
print MAIL 'To: $admin_email\n';
print MAIL 'From: $admin_email\n';
print MAIL 'Subject: DBSPEC New Record Added\n';
print MAIL '-' x 75 . '\n\n';
foreach $column(@db_cols) {
print MAIL '$column: $rec{$column}\n';
}
close MAIL;
# send mail to user
open (MAIL, '$mailprog') or &cgierr('unable to open mail program');
print MAIL "To: $rec{'Email'}\n";
print MAIL 'From: $admin_email\n';
print MAIL 'Subject: DBSPEC New Record Added\n';
print MAIL '-' x 75 . '\n\n';
foreach $column(@db_cols) {
print MAIL '$column: $rec{$column}\n';
}
close MAIL;
}
Regards,
John