Gossamer Forum
Home : Products : DBMan : Customization :

Private mailer mod problem.....

Quote Reply
Private mailer mod problem.....
OK only one more mod to go after this one !! Whew !

I am trying to install the "Private Mailer Mod" and after I have all the code in I am getting the following error when trying to send the email:

"There was a problem: There is no email address on file for this person."

Here is the sub routine for send_email from the db.cgi:


sub send_email {
# --------------------------------------------------------
# This subroutine added for the private email mod
#

unless ($in{'Email Address'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'Email Address'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
elsif (!$rec{'$db_email_field'}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message); &html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") &#0124; &#0124; &cgierr("unable to open mail program");
print MAIL "To: $rec{'$db_email_field'}\n";
print MAIL "From: $in{'Email Address'}\n";
print MAIL "Subject: $in{'subject'}\n\n"; print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL); &html_send_email_success;
}


Here is a portion of my default.cfg


# Auth user field. This is the field position in the database used for storing
# the userid who owns the record. Set to -1 if not used.
$auth_user_field = 16;
$auth_email_field = 10;

# URL to send user if they chose log off. Leave blank and the script will return to
# the logon prompt (although this only makes sense if you are using authentication).
$auth_logoff = "http://cocoahighalumni.com/cgi-bin/dbtest/";

# Fieldname that contains the email address of the user
$db_email_field = 'Email Address';

# ===========================================================================
# Build up some variables from your definitions. Internal use only.
foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) {
push (@db_cols, $_);
$db_sort{$_} = $db_def{$_}[1];
$db_form_len{$_} = $db_def{$_}[2];
$db_lengths{$_} = $db_def{$_}[3];
$db_not_null{$_} = $db_def{$_}[4];
$db_defaults{$_} = $db_def{$_}[5];
$db_valid_types{$_} = $db_def{$_}[6];
($_ eq $db_key) and $db_key_pos = $db_def{$_}[0];
}
1;

and here is the html.pl portion of the mod:

sub html_send_email_form {
#----------------------------------------------------------
my ($message) = $_[0];
%rec = &get_record($in{$db_key});
&html_print_headers;
print qq|

<html><head><title>$html_title: Send an email</title></head>
<body bgcolor="#DDDDDD"> <center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Send an email</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>Send an email</b></font></center>
<br>
|;
if ($message) {
print qq| There was a problem: $message|;
}
print qq|
<$font>Fill in your email address, the subject of your email and the
message you wish to send to $rec{'First Name'} $rec{'Last Name'}.</font> |;
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="$in{$db_key}">

<table><tr><td align=right><$font>Your email address:</font></td>
<td><input type=text name="Email Address" value="$in{'Email Address'}" size=40></td>
</tr>
<tr><td align=right><$font>Subject:</font></td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td align=right><$font>Your message:</font></td>
<td><textarea name="emailmessage" width=40 height=10>$in{'emailmessage'}</textarea></td></tr>
</table> <center>
<INPUT TYPE="SUBMIT" NAME="send_email" VALUE="Send Email">
<INPUT TYPE="RESET" VALUE="Reset Form"> </center> </form> |;
&html_footer; print qq|</td></tr></table></body></html>|;
}

Sorry this is soooooo long !

------------
donm
Quote Reply
Re: Private mailer mod problem..... In reply to
I think you have to remove the ' around the def. of your $rec{db_email_field}:
unless ($in{'Email Address'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'Email Address'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
elsif (!$rec{$db_email_field}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message); &html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") &#0124; &#0124; &cgierr("unable to open mail program");
print MAIL "To: $rec{$db_email_field}\n";
print MAIL "From: $in{'Email Address'}\n";
print MAIL "Subject: $in{'subject'}\n\n"; print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL); &html_send_email_success;
}

I've been fighting with this mod the whole weekend, so maybe this helps...

Goodluck
--------
Mart.


[This message has been edited by mart (edited August 16, 1999).]
Quote Reply
Re: Private mailer mod problem..... In reply to
Hey mart !

Thanks alot ! That did the trick !

-----------
donm