Gossamer Forum
Home : Products : DBMan : Customization :

email add record

Quote Reply
email add record
2857-00-DB

I would like to send a eMail to the user add a record in DBMAN, but I found not the right mod. The eMail send to the eMail Adress in the add record.
I must translate this eMail Adress in format name\@server.com ? ( with \)
Another mod send eMail to admin is working fine.

Thanks

Werner



Quote Reply
Re: email add record In reply to
Add the following codes to the top of sub html_add_success

%rec=&get_record($in{$db_key});

open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $rec{$db_email_field}\n";
print MAIL "Subject: New Addition of record at $html_title\n\n";
print MAIL "A new record was added at $html_title with the following information:\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;

See if it works for you.

Julian
Quote Reply
Re: email add record In reply to
If i am understanding you correctly.

To send a email to a user to let them know there record was added you would use:

# send mail to user
open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $rec{'Email'}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New Record Added\n";
print MAIL "-" x 75 . "\n\n";
foreach $column($db_cols) {
print MAIL "$column: $rec{$column}\n";
}
close MAIL;

You would change Email above to match the name of the field in your database.

Notice it uses: To: $rec{'Email'}

so it takes the email out of the database and should not require the use of using \.

Does this help or answer your question? If not, please explain at what point it is not accepting the email address and how it is being listed in your database.





Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: email add record In reply to
I've got Validate1-mode installed on a short/long + user-friendly html.pl.
the mod works but no email sent neither to admin nor to user.

when i add the following portion to my html_add_success:

%rec=&get_record($in{$db_key});

open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New Record at $html_title\n\n";
print MAIL "A new record was added at $html_title with the following information:\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;
=============================
I get the dreaded page:
HTTP 500 - Internal server error
Internet Explorer

Here how the html_add_success looks in its entirety:
%rec=&get_record($in{$db_key});

open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New Record at $html_title\n\n";
print MAIL "A new record was added at $html_title with the following information:\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;



$page_title = "Record Added to the DealCenter";
&html_page_top;

# < -- Start page text -- >
print qq|
<P><$font>The following record was successfully added to the DealCenter database:</FONT>
|;
# < -- End page text -->

&html_record_long(&get_record($in{$db_key}));

&html_footer;
&html_page_bottom;
}
=============
if you trace an anomaly in this code please answer this thread; it would be very much appreciated

cheers
macagy




Quote Reply
Re: email add record In reply to
After:

%rec = &get_record($in{$db_key});

and before:

open (MAIL, "$mailprog") or &cgierr("Can't open sendmail!\n");

Add:

&html_record_long(%rec);


Then comment out or delete the following line:

&html_record_long(&get_record($in{$db_key}));

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: email add record In reply to
Thank you loiC for your response

here I have no 500 page but the look of the record as it appears is screwed up with the header showing at the bottom after the record and no email is sent

however i've noticed that with the 500 page the record is stored for Validation and when o.k.'d it does send the email from webmaster to user
so then why do i get the 500 page?
just in case it does give you a hint i'm using Format.pl, for the top&bottom and side menu

cheers
macagy


Quote Reply
Re: email add record In reply to
I believe this line:

print MAIL "$column: $rec{$column}\n";

Should read:

print MAIL "$column: $in{$column}\n";



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: email add record In reply to
Hi loisC,

your new line of code got me an email as a user. still no email sent to admin and more importantly the look of the page is upside down (header at the bottom of page)with a line printed in the middle:between the last word of the record and the beginning of the header

admin\@loudwind.com... User unknown Content-type: text/html

LoisC thanks for your help

cheers
macagy




Quote Reply
Re: email add record In reply to
Also, make sure you have the following in default.cfg

$mailprog = "|/usr/sbin/sendmail -t"; #(if using sendmail)
$admin_email = "youraddress\@yourdomain.com";

Quote Reply
Re: email add record In reply to
watts thanks,

i did have the piece of code you mentioned; i think it's got to do with the placement of the code on my html_add_success
i'm puzzled though why is it i get as a user the validation email but not the email for a new record as an admin

i keep trying fiddling with that snippet of code

cheers
macagy


Quote Reply
Re: email add record In reply to
FLASH update!!!
follows is the new look of the sub and that translates in my header being at the right place.

sub html_add_success {
# --------------------------------------------------------
# The page that is returned upon a successful addition to the database. You should use &get_record and &html_record to verify that the record was inserted properly and to make updating easier.

$page_title = "Record Added to the DealCenter";
&html_page_top;
%rec=&get_record($in{$db_key});
&html_record_long(%rec);
open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New Record at $html_title\n\n";
print MAIL "A new record was added at $html_title with the following information:\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $in{$column}\n";


}
print MAIL "\n\n";
close MAIL;



# < -- Start page text -- >
print qq|
<P><$font>The following record was successfully added to the DealCenter database:</FONT>
|;
# < -- End page text -->



&html_footer;
&html_page_bottom;
}
but now i've got the phrase:
=====
A new record was added at $html_title with the following information
==========
repeated again at the bottom of the screen just before
View Add Home Logoff

anyone has an idea?

cheers
macagy