Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Still working on the email mod - need help please

Quote Reply
Still working on the email mod - need help please
Ok, did it!
This mod needs a form with a textfield named 'sendto' for a user to enter his email; after sending he gets a mail with all his links (Title, ID and password)
Just copy the code to password.cgi, upload it to the cgi (where add.cgi),set it to 755 and call it from the form. I use it on my modify and upload-functions, cause i protect them with the need of ID and password.

Thank you to Mr. Moretti for his version (needs url and sends only the one link)


Code:

#!/usr/bin/perl
# ==============================================================
# -------------
# Links SQL
# -------------
# Links Manager
#
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 1.11
#
# COPYRIGHT NOTICE:
#
# Copyright 1999 Gossamer Threads Inc. All Rights Reserved.
# No redistribution of this script may be made without prior
# written consent.
#
# By using this program you agree to indemnify Gossamer Threads
# Inc. from any liability.
#
# Please see the README for full license details.
#
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use strict;
use vars qw/%in/;
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'admin';
use Links;
use Links: B_Utils;
use Links::HTML_Templates;
use Links: BSQL;
$|++;

&main();

sub main {
# --------------------------------------------------------

my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
%in = %{&cgi_to_hash($in)};
print $in->header('text/html');

if ($in->param('sendto')) {

# Varible passed from the form
&process_form ($in, $dynamic);
}
else
{
&site_html_error ( { error => "Falscher Aufruf!" }, $dynamic);
}
}

sub process_form {
my ($in, $dynamic) = @_;
my ($db, $links);

# Make sure we have an email address to send the info to
if (!$in->param('sendto')) {
&site_html_error ( { error => "Bitte springen Sie zurück und geben eine E-Mail-Adresse ein!\n" }, $dynamic);
}
else
{
$db = new Links: BSQL "$LINKS{admin_root_path}/defs/Links.def";
$links = $db->query ( { Contact_Email => $in->param('sendto'), ww => 1 } );

if ($links) {

# Check to make sure that there is an admin email address defined.
$LINKS{db_admin_email} or die ("Admin Email Address Not Defined in config file!");
my ($to, $from, $subject, $msg, $mailer);
$to = $in->param('sendto');
$from = $LINKS{db_admin_email};
$subject = "Anfrage auf Handwerksfuehrer.de\n";

$msg = "Sie haben folgende Einträge im Index des Handwerksfuehrers eingestellt:\n\n";

my ($ID,$Password,$Titel);

foreach my $hit (@$links) {
$hit = $db->array_to_hash ($hit);
$ID = $hit->{'ID'};
$Titel = $hit->{'Title'};
$Password = $hit->{'Password'};


$msg = $msg ."------------------------------------------------------\nTitel: $Titel\nID: $ID\nPasswort: $Password\n\n\n";
}

$msg = $msg ."\nMit freundlichen Grüßen\n\nRobert Emmerich\nwebmaster\@handwerksfuehrer.de";
#

# Then mail it away!
require Links::Mailer;
$mailer = new Links::Mailer ( {
smtp => $LINKS{db_smtp_server},
sendmail => $LINKS{db_mail_path},
from => $from,
subject => $subject,
to => $to,
msg => $msg
} ) or die $Links::Mailer::error;
$mailer->send or die $Links::Mailer::error;






&site_html_error ( { error => "Daten wurden verschickt!\n" }, $dynamic);
}
else
{
&site_html_error ( { error => "Diese E-Mail-Adresse ist dem System nicht bekannt!\n" }, $dynamic);
}
}
}

Any questions or suggestions?



[This message has been edited by Robert (edited January 08, 2000).]
Quote Reply
Re: Still working on the email mod - need help please In reply to
Hi Robert,

Are you able to supply an english translation of what the messages are in this script? I've got it running, but have no idea what messages it's returning to me! :)

Please excuse my ignorance.

Regards

Regan Yelcich.