DarealZnarkde
New member
Hey, ich hoffe das ist die richtige Area wo ich dieses Script poste: Eigentlich müsste alles funktionieren, aber irgendwie gibt es doch Fehler und ich habe keine Ahnung warum. Ich hoffe ihr könnt den Fehler finden...
Code:
#!/usr/bin/perl
use strict;
use CGI;
my $cgi = new CGI;
my %FORM = $cgi->Vars;
my $check=0;
print ("Content-type: text/html\n\n");
open (LIST,"list.txt")|| die "The Free Thinkers page couldn't add your Email to the news mailing list. Please try it again.\n";
for (<LIST>) {
if (/$FORM{'email'}/) {
$check=1;
print "<font color=#FF0000>Your email was already in news list. To sign off use the links in your news mails.</font><br>";
}
}
close (LIST);
my @vorlage;
if ($check==0) {
open (LIST,">>list.txt")|| die "The Free Thinkers page couldn't add your Email to the news mailing list. Please try it again.\n";
print LIST "$FORM{'email'}\n";
close(LIST);
#email schicken anfang
open (VORLAGE,"templates/email_confirmation.html")|| die "The Free Thinkers page couldn't send you a confirmation.\n";
my @vorlage=<VORLAGE>;
close(VORLAGE);
$mailprog = '/usr/sbin/sendmail';
$recipient = $FORM{'email'};
open (MAIL, "|$mailprog -t") || die "The Free Thinkers page couldn't send you a confirmation.\n";
print MAIL "To: $recipient\n";
# Reply-to can be set to the email address of the sender, assuming you
# have actually defined a field in your form called 'email'.
print MAIL "Reply-to: raoul\@znark\.de\n";
# print out a subject line so you know it's from your form cgi.
# The two \n\n's end the header section of the message. anything
# you print after this point will be part of the body of the mail.
print MAIL "Subject: Mailing list confirmation\n\n";
# here you're just printing out all the variables and values, just like
# before in the previous script, only the output is to the mail message
# rather than the followup HTML page.
print MAIL "@vorlage";
# when you finish writing to the mail message, be sure to close the
# input stream so it actually gets mailed.
close(MAIL);
#email ende
open (TMP, "templates/after_addemail.html")|| die "The Free Thinkers page couldn't open a template.\n";
my @tmp=<TMP>;
close (TMP);
print "@tmp";