Three questions, Sorry!

1) I have set up a form so that people can submit there email addresses to my mailing list.
Ok I have been messing around with an autoreply and need to be able to send an "HTML" file with the autoreply thru sendmail. This way you get a GREAT email message instead of yucky text-on-text

Does anyone know how to do this?

2)Does anyone have a snippet of code that will check a existing .txt file for the email address entered and return "already added" to the user if they already added there email address? I cant seem to get one right.

3)Anyone know why The cookie i set below for +1y seems to not be there after i close my browser? Is it the way im reading it? I cant seem to use HTTP::cookie so i use $q->cookie().

heres a sample:
#!/usr/local/bin/perl use CGI; $q = new CGI; $thefile = "email.txt"; $my_email = "webmaster\@itsmeagain.com"; $email_entered = $q->param('email'); #check for email valid $FORM = $q->param('email') . ","; if ($q->param('email')) { unless ($FORM =~ /\w+@\w+.\w+/) { print $q->header(-type=>'text/html', accept=>'*/*'); print $q->start_html(-title=>'Bad Email'); #print "Content-type: text/html\n\n"; print "<html><head><title>Bad E-mail</title></head>\n" +; print "<body><h1>Bad E-mail</h1><br>The e-mail address + that you've\n"; print "entered,<b><font color='red' size='+3'> $FORM</ +font></b> is invalid. Please click back and\n"; print "try again.\n"; print $q->end_html; exit; } #chk for cookie $JSCRIPT=<<END; function go(){ if (document.referer){ window.parent.location=document.referer; } else{ document.location= "http://www.mysite.com/index2.htm"; } } setTimeout("go()", 5000); END $chkcookie = $q->cookie( "email" ); if ($chkcookie eq $email_entered){ print $q->header(-type=>'text/html', accept=>'*/*'); print $q->start_html(-title=>'Already Entered This Email', script=>$JS +CRIPT); print "<h1><b>You just entered this email address! </h1>---<font size= ++1></b>Click back to continue or wait and I'll send you!"; print $q->end_html; } else { &filewritee; } } else { print $q->header(-type=>'text/html', accept=>'*/*'); print $q->start_html(-title=>'Nothing Entered'); print "<h1>Nothing Entered.</h1><br><br>\n"; print "You didn't enter anything, Pls go back and enter a valid email +address"; print $q->end_html; } sub filewritee{ open (EMAILADDRESS, ">> $thefile") or die "Can't open file: $!"; flock EMAILADDRESS, 2; print EMAILADDRESS $FORM; close EMAILADDRESS; &sendmail; } sub sendmail{ open (MAIL, "| /usr/vde/bin/sendmail -t") or die "couldnt open sendmail: $!"; print MAIL <<EO; To: $email_entered From: $my_email Subject: Weekly mail from me EO open (FILE, "< weekly.htm") or die "Cannot open file: $!"; while (<FILE>) { print MAIL; } close FILE; close (MAIL); &successs; } sub successs{ $JSCRIPTT=<<ENDD; document.cookie = "email=$email_entered", expires="+1y"; ENDD print $q->header(-type=>'text/html', accept=>'*/*'); print $q->start_html(-title=>'-Email Added Successfully!', -script=>$J +SCRIPTT); print "<h1><font color='#000080'>SUCCESS!</h1><br><br>\n"; print <<ENDOF; <p><b>Your Email address: </font><font color='red' size='+2'> \"$email +_entered\" </font><font color='#000080'>was added successfully!<br></ +b> You should be getting your first mail shortly!</p> ENDOF print $q->end_html; exit; }

In reply to CGI, cookies, sendmail, HTML attachments, searching txt files, by dumbadam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.