Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Allow users to e-mail?

Quote Reply
Allow users to e-mail?
I looked the gt::mail code and I am little stumpedTongue
How do I add a link (Basically button) that users would click and it would automatically send an e-mail (with info like username, id, price parsed automatically to the e-mail.) to the owner of the data,
Should I create another script for this? or is it built in?

Thanks
Quote Reply
Re: [Hank] Allow users to e-mail? In reply to
As far as i know, there is now built in function for this in DBMan SQL. You need to build a plugin. However in the GT Lib are very good functions to do that. You may look at the beta version of the forum to get an idea how to use it.

Im just in the process of building an email lost password function. But this is not ready yet.
Quote Reply
Re: [Hank] Allow users to e-mail? In reply to
Hi,

Add the send_mail subroutine in Home.pm


$COMPILE{send_mail} = <<'END_OF_SUB';
sub send_mail {
#-----------------------------------------------------------------------------
#
my $self = shift;

use GT::Mail;
# Create and Sending
my $msg = $self->{cgi}->{msg} || 'Whatever';
my $to = $self->{cgi}->{to};
my $from = $self->{cgi}->{from};
my $sbj = $self->{cgi}->{sbj};

GT::Mail->send (
'Content-type' => 'text/html',
sendmail => $self->{glb_cfg}->{db_mail_path},
to => $to,
from => $from,
subject => $sbj,
msg => $msg
) or die "Error: $GT::Mail::error";
return ('home.html',{
header => $self->_language('HEA_HOME'),
msg => 'Email was sent.'});
}
END_OF_SUB

And then, add a link db.cgi?db=<%db%>&do=send_mail&msg=.....

Or you can create a plugin for this, that should be better because it won't lose when you upgrade DBMan SQL.

Hope that helps,
TheStone.

B.

Last edited by:

TheStone: Nov 13, 2001, 1:34 PM
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
Thanks
That was fast....
I am working with this and I'll see if it is what I need.

One question, Am I able to do this with above script?

I have 2 tables buyer and seller which both use same usertable.

I set up the seller to provide info about the products, and buyer to provide info about themselfs.

I want to be able to send e-mail to <%sellerEmail%> from <%buyerEmail%> with message <%sellerName%> and <%sellerID%>.

Is this possible? PM me if this sounds too confusing.
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
This is awesome... I got it working almost like I wanted.

Msg part is the one I am still working on.
I would like to provide data from seller table rather than from user table:
This is what I got and its not working just blank:
Quote:
my $msg = $self->{cgi}->{msg} || $self->{seller}->{'testfield'};


I am using link without &msg=

Last edited by:

Hank: Nov 14, 2001, 8:06 AM
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
Quote:
my $msg = $self->{cgi}->{msg} || $DB->table('seller')->insert({ testfield => $ID });

And this wont take it either....
I am looking for inserting message from seller table and from the field named testfield.

Would this be difficult, since I have 2 tables that shares same usertable.
Quote Reply
Re: [Hank] Allow users to e-mail? In reply to
I am so close with this... Crazy
I posted the question also and sample code in http://www.gossamer-threads.com/...orum.cgi?post=168937

Kindly asking your help with this... this is the main "fruit" on my database solution.

Thanks
HankSmile
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
I'm in the progress of adding the sendmail feature

and I get the following error:

Goto undefined subroutine &Dbsql::Home::send_mail at /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin/Dbsql/Home.pm line 31. Stack Trace======================================Dbsql (3004): Dbsql::Home::AUTOLOAD called at /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin/GT/Plugins.pm line 142 with arguments (Dbsql::Home=HASH(0xb4fec)).Dbsql (3004): GT::Plugins::dispatch_method called at /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin/Dbsql/Home.pm line 75 with arguments (GT::Plugins, /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin/Plugins/Dbsql, send_mail, Dbsql::Home=HASH(0xb4fec), send_mail).Dbsql (3004): Dbsql::Home::process called at /cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/db.cgi line 29 with arguments (Dbsql::Home=HASH(0xb4fec), in, GT::CGI=HASH(0xd2d58), sql, GT::SQL=HASH(0x56a200), cfg, Dbsql::Config=HASH(0x231ca4)).Dbsql (3004): main::main called at /cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/db.cgi line 22 with no arguments.System Information======================================Perl Version: 5.00404DBMan SQL Version: 2.0.3DBI.pm Version: 1.02@INC = /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin /opt/perl/packages/5.004_04/sparc-sun-solaris2.6/lib /opt/perl/packages/5.004_04/lib /opt/perl/packages/5.004_04/lib/site_perl/sparc-sun-solaris2.6 /opt/perl/packages/5.004_04/lib/site_perl .$@: Can't locate GT/Text/Tools.pm in @INC (@INC contains: /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin /opt/perl/packages/5.004_04/sparc-sun-solaris2.6/lib /opt/perl/packages/5.004_04/lib /opt/perl/packages/5.004_04/lib/site_perl/sparc-sun-solaris2.6 /opt/perl/packages/5.004_04/lib/site_perl .) at /auto/cweb0/www-home/virtual/wwwin-gsbu/cgi/seg/dbman_SQL_inventory/admin/GT/Mail/Parts.pm line 18.



I tried looking for the GT/Text/Tools.pm and it isn't apart of the package...Am I missing something?
Reena
Quote Reply
Re: [Reena0330] Allow users to e-mail? In reply to
You should create Text folder if it doesn't exist.

B.

Last edited by:

TheStone: Sep 6, 2002, 4:08 PM
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
How could I customize the send mail routine such that the mail isn't automatically sent, rather the user is redirected to a send mail page where they can fill out the e-mail info and the record information is filled in in the body of the email automatically.
Reena
Quote Reply
Re: [Reena0330] Allow users to e-mail? In reply to
You should create a template called 'send_mail_form.html' which contains:

<form name=myform action="db.cgi" method="post">
To:.....
...
<input type="hidden" name="db" value="<%db%>">
<input type="hidden" name="do" value="send_mail">
</form>

- Add the 'send_mail_form' subroutine in Home.pm

$COMPILE{send_mail_form} = <<'END_OF_SUB';
sub send_mail_form {
#-----------------------------------------------------------------------------
#
my ($self, $msg) = @_;
return ('send_mail_form.html', { msg => $msg});
}
END_OF_SUB

- add a link into your template:
<a href="db.cgi?do=send_mail_form">Send Email</a>

Hope that helps.

TheStone.

B.
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
Hi,

I added all the code that you told me to and the send mail form comes up fine, however, when I click the "Send Email" button I get an invalid action error. I've attached a copy of my send_mail_form.html.

Also, how do I make it such that the to, from, and subject fields are required and the body of the e-mail is automatically filled with the content of a record.



Thanks Cool,
Reena
Quote Reply
Re: [TheStone] Allow users to e-mail? In reply to
I keep getting an invalid action message when I try to send the e-mail. I think I'm missing the send_mail subroutine. I tried creating one:

$COMPILE{send_mail} = <<'END_OF_SUB';
sub send_mail {
#-----------------------------------------------------------------------------
#
my $self = shift;

use GT::Mail;

GT::Mail->send (
'Content-type' => 'text/html',
sendmail => $self->{glb_cfg}->{db_mail_path},
) or die "Error: $GT::Mail::error";
return ('home.html',{
header => $self->_language('HEA_HOME'),
msg => 'Email was sent.'});
}
END_OF_SUB





Based on your previous examples, but it doesn't seem to work. Also, how to I auto populate the e-mail form based on the record information? Each record has it's own "Email this Record" link. Thanks
Reena
Quote Reply
Re: [Reena0330] Allow users to e-mail? In reply to
Please any help? Frown

Promise I'll cut down my postings Wink
Reena
Quote Reply
Re: [Reena0330] Allow users to e-mail? In reply to
help Unsure
Reena