Perl script: 'test_page_send_email.cgi'
----
NOTE: This is a copy of the script used to email a diagnostic report from a Shibboleth authentication to ProQuest Technical Support. If using this as an example for your own script, please add your own email address(es) where appropriate. The email is sent using the '/bin/mailx' utility on a Solaris server. This will need to be amended to suit the email system on your own server.
#!/usr/local/bin/perl -w # Send an email from the Shibboleth authentication test page # # --------------------------------------------------------------------- # Script: /opt/shibboleth/apache2.2/cgi-bin/test_page_send_email.cgi # Author: Geoff Leach # Date: October 2007 # Copyright: © 2007 ProQuest LLC # --------------------------------------------------------------------- # # Parameters to this script are: # # REPORT Text of the 'Shibboleth authentication report' # displayed on the test page. # # LOCATION Server location: UK, US or DEV # # NAME, EMAIL, Details of the user sending the email, as entered # INSTITUTION, into the form fields on the test page. # COMMENTS # use strict; use CGI; main(); sub main { # Obtain the CGI parameters my $report = CGI::param( "REPORT" ) || ""; my $location = CGI::param( "LOCATION" ) || ""; my $name = CGI::param( "NAME" ) || ""; my $email = CGI::param( "EMAIL" ) || ""; my $institution = CGI::param( "INSTITUTION" ) || ""; my $comments = CGI::param( "COMMENTS" ) || ""; # Email address for ProQuest Technical Support my $pqemail = "your.email@your.server"; # Return address for undelivered emails my $retaddr = "your.email@your.server"; # Form the subject line for the email my $subject = "Shibboleth authentication report for " . "'$name' of '$institution'"; # Escape any quotes so as not to confuse the shell $subject =~ s/"/''/g; # Form the body of the email my $body = "Name: $name \n" . "\n" . "Email address: $email \n" . "\n" . "Institution: $institution \n" . "\n" . "Comments: \n" . ( "-" x 76 ) . "\n" . $comments . "\n" . ( "-" x 76 ) . "\n" . "\n" . "Shibboleth authentication report: \n" . ( "-" x 76 ) . "\n" . $report . "\n" . ( "-" x 76 ) . "\n" . "\n"; # Send the email my $mailcmd = "/bin/mailx -r $retaddr -c $email -s \"$subject\" $pqemail"; open( EMAIL, "| $mailcmd" ); print EMAIL $body; close( EMAIL ); # Output a confirmation page print CGI->header( -type => "text/html" ); my $title = "Test Page for Shibboleth Authentication - $location Server"; print "<head>\n" . "<title>$title</title>\n" . "</head>\n"; print "<body>\n" . "<h2>$title</h2>\n"; print "<p>Thank you.</p>\n" . "<p>Your email has been sent to ProQuest Technical Support, " . "and a copy has been sent to your email address '$email'.</p>\n"; print "</body>\n" . "</html>\n"; exit( 0 ); }