Let’s look at a simple example that illustrates how email is sent using a CGI script. I’ve written a CGI script (email-form.pl) that presents users with a form that requests their email address, a subject, and a message body. When the user fills out the form fields and submits the form, an email message with the subject and body that they entered is sent to the email address specified in the script. Theoretically, the email address is their own, but that’s not necessary. The full source code for the script appears in Listing 8.2.
1: #!/usr/local/bin/perl 2: 3: use CGI; 4: use Net::SMTP; 5: 6: my $query = new CGI; 7: my $smtp = Net::SMTP->new('localhost'); ...