3 - Sending email with Perl
Perl scripts, thankfully, have the ability to send email. Not only that, but the text inside the email and the address it is sent to can be specified using variables. You know what that means: users entering their email addresses, and receiving almost instant confirmation emails! Don't worry, doing this is not at all difficult. Create a file called email.html, and enter this HTML into it:
<html> <head> <title>Signup Page</title> </head> <body> <h3>Signup Today!</h3> <form action="http://www.yourdomain.com/cgi-bin/email.cgi" method="post"> <b>Email Address:</b> <input type="text" name="email"> <input type="submit" value="Signup"> </body> </html>
Once again, don't forget to substitute the form action URL with the path to your email.cgi file. Next, create a new text file, name it "email.cgi", and enter this into it (the first few lines or so should look familiar):
#!/usr/local/bin/perl require "subparseform.lib"; &Parse_Form; $email = $formdata{'email'};
Alright, now we move into uncharted territory. Brace yourself:
open (EMAILS, ">>emails.txt"); flock(EMAILS, 2); print EMAILS "$emailn"; flock(EMAILS, 8); close (EMAILS);