Gossamer Forum
Home : Products : DBMan : Installation :

For the message is hollow and I have not quite touched the sky

Quote Reply
For the message is hollow and I have not quite touched the sky
I'm nearly there on my sending mail to an email address in the database via a ew sub. I figured out why no message was being sent (I'd stupidly forgotten the "/n" after the "TO:" Smile

What I'm trying to do now is quite a bit trickier. What I am trying to do is as follow:

(Where User is a user with permission to add, view and modify records, and has a record of their own.)

1. User does a search, bringing up 4 records: record W through Z.

2. User Clicks on a link within record X, thus bringing up a window containing a form.

3. User types message into text area within form and clicks send.

4. The sub send_message sends the contents of the text box to the email address entered in Record X (but User is never able to see this email address, not even as a hidden field.) Included in this message is the contents of the record belonging to User.

5. The send-mail sub redirects User to a "message sent" page.

6. I sing and dance a jig.

Of those 6 steps, I have managed to make the first 3 and a half work Smile The sub sends the message to an address I have stipulated (I haven't been able to bring the address from a record yet) but however - User's record is NOT shown.

I now need to get User's record to show in the message, and the send_message sub to pull the email address from Record X WITHOUT User seeing it.

Following is the send_message sub - which is being called fine, but not doing what I outlined

sub send_message {
#---------
#Send Message to user Build 1
#---------


#my ($message, @lines, $line);
#my ($output, $status, $counter);
my $tft = "Table For Two";
my %rec = &get_record($db_key);

# Set the userid to the logged in user.
if ($auth_user_field >= 0) {
$in{$db_cols[$auth_user_field]} = $db_userid;
}


$mailprog = "/var/qmail/bin/qmail-inject";



open (MAIL, "|$mailprog -t")
| | print "Can't start mail program";
print MAIL "To: lmoss\@ihug.co.nz\n"; # $I'm not sure what this var should be{'Email'}\n";
print MAIL "From: lmoss\@ihug.co.nz\n"; #$rec{'Name'} (Posted from $tft)\n";
print MAIL "Subject: A message from\n"; # $rec{'Name'} posted from $tft\n";
print MAIL "-" x 60 . "\n\n";

print MAIL "$in{'Message'}\n\n";
}

print MAIL "Some information about $rec{'Name'}:\n\n";
print MAIL "Age: $rec{'Age'}\n";
print MAIL "Sex: $rec{'Sex'}\n";
print MAIL "City: $rec{'City'}\n";
print MAIL "State: $rec{'State'}\n";
print MAIL "Country: $rec{'Country'}\n";
print MAIL "Height: $rec{'Height'}\n";
print MAIL "Weight $rec{'Weight'}\n";
print MAIL "Hair: $rec{'Hair'}\n";
print MAIL "Eyes: $rec{'Eyes'}\n";
print MAIL "Seeking: $rec{'Seeking'}\n";
print MAIL "Comments: $rec{'Comments'}\n";
print MAIL "Homepage: $rec{'Homepage'}\n";
print MAIL "ICQ: $rec{'ICQ'}\n\n";
print MAIL "-" x 60 . "\n\n";
print MAIL "To reply to this message, log on to $tft (http://tablefortwo.hypermart.net)\n";
print MAIL "and search for $rec{'ID'} on the locator.\n\n";
foreach $line(@closing) {
print MAIL "$line";
}
print MAIL"\n\n";
close (MAIL);

&message_sent;
}
#End of send_message
#---------------------------------------------------------

Thanks in advance for any help anyone can give me Smile

[This message has been edited by Samuel (edited December 05, 1998).]
Quote Reply
Re: For the message is hollow and I have not quite touched the sky In reply to
 
Quote:
my %rec = &get_record($db_key);

Hmm.. that's trying to pull up record with a key value equal to your key's name. Not what you want. You could try something like:

$in{'userid'} = $db_userid;
($status, @results) = &query('view');

which should pull up his record into @results (assuming only one record per user and that your user field is called userid).

Throw that into &array_to_hash and your set!

Hope that helps!

Alex
Quote Reply
Re: For the message is hollow and I have not quite touched the sky In reply to
Alex - Thanks for the tip! I've tried that, but I don't think that I'm puting data into the hash correctly, so nothing is coming out the other end...... Here's how I'm trying to do it:

$in{'userid'} = $db_userid;
($status, @results) = &query('view');


$mailprog = "/var/qmail/bin/qmail-inject";

my %tmp = &array_to_hash(@results);

open (MAIL, "|$mailprog -t")
| | print "Can't start mail program";
print MAIL "To: $tmp{'email'}\n";
print MAIL "From: lmoss\@ihug.co.nz\n";
print MAIL "Subject: A message from\n";
print MAIL "-" x 60 . "\n\n";

print MAIL "$in{'Message'}\n\n";
print MAIL "Some information about $tmp{'Name'}:\n\n";

Is this correct? Even when I try and print out all the contents of $tmp I get no values.

Any help would be greatly apprectiated Smile