Gossamer Forum
Home : Products : DBMan : Customization :

How to Email to database record?

Quote Reply
How to Email to database record?
Hi,

I'm trying to set up a method for a surfer to email the owner of a record in my database.

I have the email address written to the database but NOT displayed in the search results (no spam food).

What I want is to have a reply button, (or form added to each records display), which will look to the database, get the email addy, and send an email response from the surfer to the owner of the record.

This seems simple enough but I'm not successful trying to get it to work.

It's a Unix system.

Any ideas?
Quote Reply
Re: How to Email to database record? In reply to
It would be possible for you to have a textarea on a form where someone could write the email message and then, when the form is submitted, it would look up the email address and send the text from the textarea. It would require a new subroutine in db.cgi to accomplish this -- a little more extensive than I can give you on the forum and would take a bit of pondering.

------------------
JPD





Quote Reply
Re: How to Email to database record? In reply to
I'm lost trying to do this. I'm willing to pay for someone who can do this mod for me. It's important for me to get it done soon. Anyone interested?
Quote Reply
Re: How to Email to database record? In reply to
Send me email at hall@drizzle.com .



------------------
JPD





Quote Reply
Re: How to Email to database record? In reply to
I also have users emailaddress in default.pass, how to private email to the user via emial in the file,default.pass...I dont want they confuse between email address in the new added field and the email by registered.,So i dont add the email field.
the format in the file is below;
webmaster:FHsaFszNyh.xg:1:1:1:1:0:mymail@hotmail.com

I f you wan t my email ,this is mine anantchai@hotmail.com

Thank you ;-)

Quote Reply
Re: How to Email to database record? In reply to
It would just require a few changes to the "Private Mailer" mod at http://www.jpdeni.com/...Mods/spam_buster.txt.

In sub html_send_email_form change

<input type=hidden name="$db_key" value="$in{$db_key}">

to

<input type=hidden name="userid" value="$rec{$db_cols[$auth_user_field]}">

In sub send_email, change

Code:

%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>" }
to

Code:

open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@lines = <PASS>;
close PASS;

$found=0;
foreach $line (@lines) {
if ($line =~ /^$in{userid'}:/) {
$found = 1;
my $to_email = (split (/:/, $line))[7];
last;
}
}

unless (!$found) { $message .= "The user you requested could not be found.<BR>"; }
and change

print MAIL "To: $rec{$db_email_field}\n";

to

print MAIL "To: $to_email\n";

That should work fine.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: How to Email to database record? In reply to
I have test and found that I need not to do modify anything just use the mod spam written by JPDeni.It function with the email address in the password file and when record owner chang the email address the mod still work fin ecoz ,the change email mod will change all email in database file aswell...Thank for JPDeni.
Quote Reply
Re: [JPDeni] How to Email to database record? In reply to
Actually, to make the following code snippet work:

Code:
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@lines = <PASS>;
close PASS;

$found=0;
foreach $line (@lines) {
if ($line =~ /^$in{userid'}:/) {
$found = 1;
my $to_email = (split (/:/, $line))[7];
last;
}
}

unless (!$found) { $message .= "The user you requested could not be found.<BR>"; }

I had to change it to this:

Code:
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@lines = <PASS>;
close PASS;

$found=0;
foreach $line (@lines) {
if ($line =~ /^$in{'userid'}:/) {
$found = 1;
$to_email = (split (/:/, $line))[7]; # remove the my operator
last;
}
}

unless (!$found) { $message .= "The user you requested could not be found.<BR>"; } # this unless code doesn't work at all.
Quote Reply
Re: [scottv] How to Email to database record? In reply to
Quote:
unless (!$found) { $message .= "The user you requested could not be found.<BR>"; }

That's because it is saying to append the message to $message if $found exists.

It should be:

Code:
if (!$found) { $message .= "The user you requested could not be found.<BR>"; }
Quote Reply
Re: [RedRum] How to Email to database record? In reply to
Paul,
Not that I'm not grateful for your reply, but "been there, done that".
Code:

if (!$found) { $message .= "The user you requested could not be found.<BR>"; }

Substituting if for unless in the code provides the same negative results - the form is dully processed as if the user account existed and the sender receives an HTML page that says their message was successfully sent.

Scott
Quote Reply
Re: [scottv] How to Email to database record? In reply to
Ok well .= should be changed to = as I don't see where $message is previously defined.

Also how is $message used - don't you need something like:

Code:
if (!$found) {
print some error;
exit;
}