#!/usr/bin/perl use strict:; use 5.010; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); use MIME::Lite; $to = 'abcd@gmail.com'; $from = 'webmaster@yourdomain.com'; $subject = 'Test Email'; $message = 'This is test email sent by Perl Script'; $message2 = '

This is test email sent by Perl Script

'; my $q = new CGI; print $q->header; print $q->start_html(-title => 'A web form'); print $q->start_form; print $q->start_form( -name => 'main_form', -method => 'GET', -enctype => &CGI::URL_ENCODED, -onsubmit => 'return javascript:validation_function()', -action => '/where/your/form/gets/sent', # Defaults to # the current program ); #without any parameters
print $q->end_form; open(MAIL, "|/usr/sbin/sendmail -t"); # Email Header print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; print MAIL "Content-type: text/html\n"; $msg = MIME::Lite->new( From => $from, To => $to, Cc => $cc, Subject => $subject, Data => $message ); $msg->send; # Email Body print MAIL $message; close(MAIL); print "Email Sent Successfully\n"; exit;