Indiana University

IU Webmaster

Sending Emails from Perl Script on Veritas/Champion

  • The purpose of this document is to help the Veritas/Champion account holders get started with developing their Web front for sending Emails using Perl Script.
  • Please note that the IU WebMasters will not be providing services related to programming or scripting.

1. With the following code, create a simple html page to get the email address of your user.

<html> <head><title>Perl Test Script</title></head> <body> <form method='post' action='test.pl'> <p>Please provide us your name and your email address. <br>We will send the information to you via email. <p> Please enter your name:<br> <input type='text' name='name' size='35'><br> Please enter your email address:<br> <input type='text' name='email' size='35'><br> <p></p> <input type='submit' value='Send Address'> <input type='reset' value='Start Over'> </form> </body> </html>

2. This code will send the email to the email address provided by the user.

(i) Copy the following code in the same directory as the above html file and save it as test.pl, since the action in the form tag of the above html code is given as test.pl.
(ii) Set the permission of the perl script 700 with the command, chmod 700 test.pl.

#!/usr/local/bin/perl use CGI; $q = new CGI; $name = $q->param('name'); $email = $q->param('email'); #Replace "your_account_name" in the From field with your email address. #You must precede each @ in the address with a backslash, # so that Perl doesn't think it's an array open(MAIL, "| /usr/lib/sendmail -oi -t"); print MAIL <<EMAIL_TO_USER; To:$email From:"your_account_name"\@indiana.edu Subject: More Information Dear $name: Thank you for contacting us. We will send you the material to this email address. EMAIL_TO_USER close MAIL; print "Content-type:text/html\n\n"; print <<HTML_RESPONSE; <html> <title>Thank You Page</title> <h1>Thanks!</h1> Thanks, $name!<br> I'll mail information to $address right away. </html> HTML_RESPONSE