Gossamer Forum
Home : Products : DBMan : Customization :

Auto insert of email address

Quote Reply
Auto insert of email address
I am using the following sub to send email to users that are registered in our database.

What I am trying to do is get the senders email address auto-inserted rather than having to type it into a field.

Any ideas how I can do this with the following sub?

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

&html_page_top;
print qq|

<table border=0 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=600 align=center valign=top>
<tr><td class="tofronttext"><b>Send an email to $rec{'FirstName'} $rec{'LastName'}</b><br>
|;
if ($message) {
print qq| There was a problem: $message|;
}
print qq|
Fill in your email address, the subject of your email and the message you wish to send
to $rec{'FirstName'} $rec{'LastName'}.
|;
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 class="tofronttext">Your email address:</td>
<td><input type=text name="EmailAddress" value="$in{'EmailAddress'}" size=40></td>
</tr>
<tr><td align=right class="tofronttext">Subject:</td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td align=right valign="top" class="tofronttext">Your message:</td>
<td><textarea name="emailmessage" rows=20 cols=50>$in{'emailmessage'}</TEXTAREA></td></tr>
</table><center>
<input type="submit" name="send_email" value="Send Email" STYLE="background-color:#eeeeee;border:1 solid #999999; Cursor:HAND">
<input type="submit" value="Reset Form" STYLE="background-color:#eeeeee;border:1 solid #999999; Cursor:HAND">
</center>
</form>
|;
&html_footer;
&html_page_bottom;
}

TIA,

Donm
Quote Reply
Re: [donm] Auto insert of email address In reply to
Sounds like you'd be interested in the 'mass email mod' - I have never used it, but I get the idea that it is designed for what you are wanting. Check it out and see what you think.
Quote Reply
Re: [Watts] Auto insert of email address In reply to
No, I have the mass mail mod installed. I think I might not have explained what it is I am trying to do well enough.

I have an Alumni Database that uses DBMan, and each user must register to enter the database. If a user would like to email another Alumnus listed in the database they click on a link which uses the "private mailer" sub listed above.

In which they type in their email address, subject of their message, and then message to send to the Alumnus.

What I am trying to figure out how to do - is not give them an option to type in an email address (sometimes they use bogus addresses) - but automatically pull the "senders" email address from the database and insert it into the "from" field.

I hope that I explained that better this time.

Any ideas?

TIA,

Donm
Quote Reply
Re: [donm] Auto insert of email address In reply to
Ah... kinda like "classmates.com". Got you.

Where is the user when he clicks on the email button? In a "view all" type of listing, or on a particular alumnus' personal listing/page? (or both?).

An easy way would be to make the user's login name his/her email address - of course that be kinda hard to do now (after the fact).

There are several ways to do this:

1. added users email to the .pass file (but this would involve some retro engineering)

2. load the user's home page/profile when they login and grab their email address and then pass it along as a hidden tag when they go from page to page.

Last edited by:

Watts: Nov 7, 2003, 8:16 AM
Quote Reply
Re: [Watts] Auto insert of email address In reply to
This reference from the FAQ noted below might also help:

Personalized email (logged in users)

Thread reference:http://gossamer-threads.com/scripts/forum/resources/Forum12/HTML/002703.html
Topic: Name in email
johnsonny - posted April 20, 2000 01:26

In order to use my Dbman, all user have to be registered user. When user A send a email in the Dbman to user B (sub html_send_email_form), the email user B received would show up like the following:

"Hi User B,
User A would like to thanks for all your help...."

I dont want the user A to use the other nick name for sending email to user B. No matter how they email each other in the Dbman..all the name in the email would be the name field that they fill in when adding a record.

JPDeni:

You're using the Private Mailer, right? (I need to make sure we're talking about the same mod.)

At the beginning of sub html_send_email_form, there is the following code:

$in{$db_key} =~ s/<?.B>//g;
%rec = &get_record($in{$db_key});

At that point, all of the information for the recipient of the email is in the %rec hash and you can use the $rec{'FieldName'} variables there just like you do in sub html_record.

You could then, if you wanted, get the sender's record as well. And put in whatever message you want into the textarea.

Something like this in your sub html_send_email_form:

%sender = &get_record($db_userid);
%rec = &get_record($in{$db_key});
unless ($in{'emailmessage'}) {
$in{'emailmessage'} = qq| Hi, $rec{'Name'},
$sender{'Name'} would like to thank you for all your help... |;
}

This is assuming that your userid is your $db_key field.

For the recipient of the email, use: $rec{'FieldName'}
For the sender of the email, use: $sender{'FieldName'}

You can put any message you want as a beginning of the email that will go into the textarea.

If a default user is logged in, nothing will be found when &get_record is called, so the %rec2 hash will be empty. In the places where it is referenced, nothing will be entered. (Unless there is a record with the userid of "default" in there, which would not be a good idea.)

It would be a good idea to be sure that this code is used only if you are certain that the person using it is a logged in user. Not that it will cause any real problems, but you might end up with something like:

Hello, John,
wanted to say hi.

--------
I'm sure you can use this information to automatically add the sender as the logged in user.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/