6
Mail with Perl/CGI Please use speaker notes for additional information!

Mail with Perl/CGI Please use speaker notes for additional information!

Embed Size (px)

Citation preview

Page 1: Mail with Perl/CGI Please use speaker notes for additional information!

Mail with Perl/CGI

Please use speaker notes for additional information!

Page 2: Mail with Perl/CGI Please use speaker notes for additional information!

<html><head><title>Mail</title></mail><body><h1>Alumni Information</h1><form action="mailtest1.cgi" method=post>Name: <input type=text name=name size=25><br><br>Year Graduated: <input type=text name=yrgrad size=4><br><br>Job: <input type=text name=job size=35><br><br>email: <input type=text name=email size=35><br><br><input type=submit value="Submit"><input type=reset value="Reset"></form></body></html>

This form takes in name, year of graduation , job and email and passes the information to mailtest1.cgi which is stored in the same directory as this program (mailtest1.html).

Page 3: Mail with Perl/CGI Please use speaker notes for additional information!

#!/usr/bin/perlprint "Content-type: text/html\n\n";use CGI::Carp qw(fatalsToBrowser);use CGI qw(:standard);

use Net::SMTP;use strict;

my($name, $yrgrad, $job, $email, $msg, $smtpserver);$smtpserver = "mail.pgrocer.biz";$name = param('name');$yrgrad = param('yrgrad');$job = param('job');$email = param('email');$msg = "Thank you for the information. We appreciate your continued interest in BCC.";print "<html>\n";print "<head><title>Alumni Response</title></head>\n";print "<body>\n";print "<h1>CIS Alumni - Bristol Community College</h1>\n";print "<h2>$msg</h2>\n";print "</body></html>\n";

Page 4: Mail with Perl/CGI Please use speaker notes for additional information!

# send email

my $smtpobj = new Net::SMTP( "$smtpserver) or die( "Cannot send email: $!" );

$smtpobj->mail( "pgrocer\@pgrocer.biz" );$smtpobj->to( "$email" );$smtpobj->data();$smtpobj->datasend( "From: BCC CIS Dept.\n" );$smtpobj->datasend( "To: $email\n" );$smtpobj->datasend( "Subject: BCC CIS Alumni\n" );$smtpobj->datasend( "$msg\n" );$smtpobj->dataend();$smtpobj->quit();

Alternate:The HELLO should be invoked automatically and should not be needed with the Net:SMTP object.

my $smtpobj = new Net::SMTP( "$smtpserver", HELLO => "$smtpserver" ) or die( "Cannot send email: $!" );

Set up an instance of the SMTP package.

Page 5: Mail with Perl/CGI Please use speaker notes for additional information!
Page 6: Mail with Perl/CGI Please use speaker notes for additional information!