Gossamer Forum
Home : Products : DBMan : Customization :

Help with Sendmail related problem

Quote Reply
Help with Sendmail related problem
Hi Folks,
I am at my wits end ... again. This time over a sendmail related error. This is what I get : Error - Can't start mail program.
It was working before I added the private mailer program.
Thanks
Kwabena

Files:
http://www.presec-legon.com/html_pl.txt
http://www.presec-legon.com/db.txt



Quote Reply
Re: Help with Sendmail related problem In reply to
Ok,
I have isolated the error. These snippets are in the html.pl file :

########
# To send mail to the admin after a record is added
################
my (%rec) = &get_record($in{$db_key});

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title New Record\n\n";
print MAIL "The following new record has been added to the database:.\n\n";
foreach $col ($db_cols) {
print MAIL "$col -- $rec{$col}\n";
}
close (MAIL);

# To send mail to the user after a record is added
###########################################################

my (%rec) = &get_record($in{$db_key});

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $rec{'Email'}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: Welcome to $html_title\n\n";
print MAIL "Dear $rec{'Full Name'},\n.
Thank you for responding to the Odadee RollCall.";
close (MAIL);
#######################3
Why?


Quote Reply
Re: Help with Sendmail related problem In reply to
Make sure $mailprog is defined correctly.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Help with Sendmail related problem In reply to
Paul : "Make sure $mailprog is defined correctly."

That exactly is my dilemma. All the other routines that utilize $mailprog are working just fine. Is there something
special to be done when you are calling creating an email in the html_pl?
Thanks

Quote Reply
Re: Help with Sendmail related problem In reply to
Don't think so - It should be working fine.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Help with Sendmail related problem In reply to
I notice one difference between your codes and the ones I'm using. Don't know if this would help.

the line foreach $col ($db_cols) {

shouldn't it be for each $col (@db_cols) {

Also, is your $mailprog defined in your cfg with "| sendmail -t-oeq" or is it just "sendmail"?

Julian
Quote Reply
Re: Help with Sendmail related problem In reply to
Below is the $mailprog line from my .cfg file:
$mailprog = "|/usr/local/bin/sendmail -t -oeq";
Only the snippets shown in my earlier post result
in the error. Correcting "foreach" doesn't help either.
Thanks
Kwabena


Quote Reply
Re: Help with Sendmail related problem In reply to
Here is code that I know works (note some differences):

####### Sends E-mail to Admin #########
open (MAIL, $mailprog)||&cgierr("Can't start mail prog");
print MAIL "To:$admin_email\n";
print MAIL "From:$admin_email\n";
print MAIL "Subject: Completed Application\n\n";

foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}

close MAIL;
######### end e-mail program #########



Here is another really nifty code that allows you to write to & e-mail a file and/or send an external "form" letter:

############# Begin e-mail attachment program

$mailprog = "/usr/sbin/sendmail"; # Sendmail Location
$youremail = "mail\@yourdomain.com"; # Your Email Address
$yourname = "Loan Application"; # Your Name
$aftersend = "http://www.yourdomain.com/"; # Where to go after
$file = "app.1003"; # File to send to user

# Send instruction/confirmation page?
# 0 = no, 1 = yes
$automessage = "1";

open(MAIL, "|$mailprog -oi -t") or die;

print MAIL <<"END";
From: $yourname
To: $youremail
Subject: File: $file (uuencoded)

Requested File: $file

END
open(FILE, "uuencode $file $file|") or die;
while( <FILE>) { print MAIL; };

# Close the file and finish sending the mail

close(FILE);
close(MAIL);


if ($automessage eq '1') {

open(MAIL, "|$mailprog -oi -t") or die;

print MAIL <<"END";
From: $yourname
To: $youremail
Subject: Your Form Letter Name

END

### Specify form letter text file
open(FILE, "efile.letter") or die;
while( <FILE>) { print MAIL; };
close(FILE);
close(MAIL);
}
########## End E-mail attachment program


Quote Reply
Re: Help with Sendmail related problem In reply to
Try using changing this a bit to include the code in red:

####### send email when record added ############
%rec = &get_record($in{$db_key});
&html_record(%rec);
open (MAIL, "$mailprog") or &cgierr("Can't open sendmail!\n");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: Record Added - $html_title\n\n";
print MAIL "A new record was added to $html_title with the following key value:\n";
print MAIL "$rec{$db_key}\n\n";
close (MAIL);
####### end send email when record added ############

and then comment out this line:

# &html_record(&get_record($in{$db_key}));

If using the short/long mod it would be:

# &html_record_long(&get_record($in{$db_key}));

and the code in red would refer to html_record_long also.

Hope this helps, if not, view some of the email references and read the Tidbits in the FAQ noted below.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
STMP address In reply to
Hello
I’m running Dbman on my local PWS we use MS exchange as a mail server . can I let dbman to send me an email if any user updates his/her recorders ?
If yes where should I insert our STMP address ?
Thanx
Cool

Quote Reply
Re: STMP address In reply to
SMTP mail routines have been discussed, addressed, posted on quite a few occassions in this forum.

Search for SMTP using All posts in the Date Range field in the Forum's Search Form.

Regards,

Eliot Lee
Quote Reply
Re: Help with Sendmail related problem In reply to
Hi Lois - thanks for getting back to me on this one.
I can't figure out your code. When I edit it I either get an Internal Server 500 Error or elase nothing changes.

Here's my actual code:

# Send Admin an E-mail when a new record is added
my (%rec) = &get_record($in{$db_key});

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $db_userid\n";
print MAIL "Subject: $html_title New Record\n\n";
print MAIL "The following new record has been added to the database:.\n\n";
foreach $column(@db_cols) {
print MAIL "$column: $in{$column}\n";
}
print MAIL "\n\n";
close (MAIL);

This works in that it sends me an e-mail as follows:

The following new record has been added to the database:.

Club:
Player Name:
Address:
Date Of Birth:
Gender:
Baseball:
Umpire:
Telephone One:
Telephone Two:
Email:
Registered:
PlayerID:
Date Added:
Date Amended:
Validated By IBSF:
Record Owner:

However as you can see - the actual data entered is missing. It's a database to monitor players on a softball team. Any help would be appreciated.

Thanks,
Gemstorm.

Quote Reply
Re: Help with Sendmail related problem In reply to
Using

"|/usr/sbin/sendmail -t -oeq"

in the config file doesn't work on my server, I get the can't start mail prog! BUT

"|/usr/sbin/sendmail -t"

does work! So try cutting out the -oeq bit.

Here's the full lot of variables from my config file:

# Full path to sendmail on your system
$mailprog = "|/usr/sbin/sendmail -t";
# Your email address
$admin_email = 'name@yourdomain.com';
# The name of the database or organization that's running it
$db_name = "Name";
# The number of your email address field
$email_field_number = 2;

It's used with JPDeni's send email mods