Gossamer Forum
Home : Products : DBMan : Customization :

Re: Email Notification with a BIG Twist

Quote Reply
Re: Email Notification with a BIG Twist In reply to
Here are the codes: (For SMTP Mailer and Sendmail)

==========================================
SMTP Mailer
==========================================
You must first download the Mailer.pm, which is available in the LINKS package. Then in your default.cfg file, add this line of code in your authorization section:

Code:
# Full path and file name of the Mailer Program.
require $mailer_path . "/Mailer.pm";

Then in the default.cgi file, add this line of code:

Code:
$mailer_path ="/path/cgi-bin/sendmail";

For a simple message that will send out an email message notifying the webmaster or data manager that a record has been added, use these instructions:

In add_record sub-routine in default.cgi:

1) Add the following codes AFTER &html_add_success; in the add_record:

Code:
# Send email when new record is added

my $mailer = new Mailer ( { smtp => 'SMTPSERVER' } ) or die "Can't init mailer: $Mailer::error";

$mailer->send ( {
to => 'Recipient Email Address',
from => 'Your Email Address',
subject => "Record Added to Database",
msg => "Message"
} )
or die "Can't send mail: $Mailer::error";

2) Replace the following statements:

* SMTPSERVER = Your SMTP Server
* Recipient Email Address = Your email address
* Your Email Address = Your email address or the server admin address
* Message = Message you want to send.

If you want to send a detailed message to the record owner, use these instructions:

In add_record sub-routine in default.cgi:

1) Add the following codes AFTER ($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);:

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

2) Add the following codes AFTER &html_add_success; in the add_record:

Code:
# Send email when new record is added

my $mailer = new Mailer ( { smtp => 'SMTPSERVER' } ) or die "Can't init mailer: $Mailer::error";

$mailer->send ( {
to => '$in{'Email'},',
from => 'Your Email Address',
subject => "Record Added to Database",
msg => "Message"
} )
or die "Can't send mail: $Mailer::error";

3) Replace the following statements:

* SMTPSERVER = Your SMTP Server
* Your Email Address = Your email address or the server admin address
* Message = Message you want to send.

Note: In the Message variable ($msg), you can add a complete record report by including fields in the following fashion:

$in{'FieldName'}

Change FieldName with the appropriate field name(s) that are located in your default.cfg file.

==========================================
Sendmail Program
==========================================
For a simple message that will send out an email message notifying the webmaster or data manager that a record has been added, use these instructions:

1) In default.cfg, add these lines of code after the reference for html.pl

Code:
# Full path to sendmail on your system
$mailprog = "|/usr/lib/sendmail -t -oeq";

# Your email address
$admin_email= 'YOUR EMAIL ADDRESS';

Replace YOUR EMAIL ADDRESS with your email address.

In add_record sub-routine in default.cgi:

2) Add the following codes AFTER &html_add_success;:

Code:
open (MAIL, "$mailprog") | | &cgierr("unable to open mail program");
print MAIL "To : youraccount\@server.com\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: Record Added to $html_title\n\n";
print MAIL "You have added a record to the $html_title\n\n";
close (MAIL);

Replace the bolded statement with your email addresses. Make sure that you put a \ before @.

If you want to send a detailed message to the record owner, use these instructions:

In add_record sub-routine in default.cgi:

1) Add the following codes AFTER ($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);:

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

2) Add the following codes AFTER &html_add_success; in the add_record:

Code:
open (PASSWD, "<$auth_pw_file") or &cgierr("unable to open password file. Reason: $!\n");
if ($db_use_flock) {
flock(PASSWD, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
@passwds = <PASSWD>;
close PASSWD;
foreach $pass (@passwds) {
if ($pass =~ /^$db_userid:/) {
@data = split ":",$pass;
$email = $data[7];
last;
}
}
open (MAIL, "$mailprog") | | &cgierr("unable to open mail program");
print MAIL "To: $email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: Record Added to $html_title\n\n";
print MAIL "You have added a record to the $html_title\n\n";
print MAIL "Please save this message for future reference.\n\n";
print MAIL "Your record ID is: $rec{'ID'}\n\n";

Note: In the Message variable ($msg), you can add a complete record report by including fields in the following fashion:

$rec{'FieldName'}

Change FieldName with the appropriate field name(s) that are located in your default.cfg file.

This particular modification requires the NEWEST password lookup mod. But you could just delete the codes before open (MAIL...and add the EMAIL field in the To line. (If you have an email field).

These modifications can be added to the modify_record and delete_record. Make sure that you insert the "mailing" codes ($mailer or open (MAIL...) after the following codes:

In modify_record:

Code:
&html_modify_success;

In delete_records:

Code:
&html_delete_success;

I really hope this helps. If you have any questions, let me know.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 04, 1999).]
Subject Author Views Date
Thread Email Notification with a BIG Twist Eliot 6033 Aug 3, 1999, 12:27 PM
Post Re: Email Notification with a BIG Twist
JPDeni 5908 Aug 3, 1999, 7:37 PM
Post Re: Email Notification with a BIG Twist
Eliot 5916 Aug 3, 1999, 7:43 PM
Post Re: Email Notification with a BIG Twist
JPDeni 5899 Aug 3, 1999, 8:14 PM
Post Re: Email Notification with a BIG Twist
Eliot 5911 Aug 3, 1999, 8:22 PM
Post Re: Email Notification with a BIG Twist
Eliot 5913 Aug 4, 1999, 5:25 AM
Post Re: Email Notification with a BIG Twist
Eliot 5900 Aug 4, 1999, 6:57 AM
Post Re: Email Notification with a BIG Twist
Eliot 5892 Aug 4, 1999, 7:52 AM
Post Re: Email Notification with a BIG Twist
JPDeni 5958 Aug 4, 1999, 9:07 AM
Post Re: Email Notification with a BIG Twist
compu_tel 5941 Aug 4, 1999, 10:02 AM
Thread Re: Email Notification with a BIG Twist
Eliot 5924 Aug 4, 1999, 10:50 AM
Thread Re: Email Notification
omegadm 5897 Jul 27, 2000, 8:00 AM
Thread Re: Email Notification
LoisC 5935 Jul 27, 2000, 11:12 AM
Post Re: Email Notification
omegadm 5948 Jul 27, 2000, 3:12 PM
Thread Re: [Eliot] Email Notification with a BIG Twist
mabel 5685 Dec 11, 2002, 12:27 AM
Post Re: [mabel] Email Notification with a BIG Twist
LoisC 5665 Dec 11, 2002, 9:14 PM
Post Re: Email Notification with a BIG Twist
Eliot 5909 Aug 4, 1999, 12:32 PM