plvicente has asked for the wisdom of the Perl Monks concerning the following question:
Hello Perl Monks. I am coding cgi for an Application Company need. My background is Unix and Red Hat. I am testing my code on a fedora 33 and 34. I tested the 34 a few days ago. I am writing a cgi send mail I found a way. The issue is giving a complete form in html into send mail through cgi. I cannot see clearly today my mistake done today.
#!/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 = '<h1>This is test email sent by Perl Script</h1>'; 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 <form method="post" action="/cgi-bin/yourprogram.pl" enctype="application/x-www-form-urlencoded"> 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;
I appreciate your help for a perl cgi newbie. I was in perl unix system background. Never coded cgi. I am reading your old docs at wayback machine. Kind Regards Monks, plvicente
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: send mail cgi
by marto (Cardinal) on May 06, 2021 at 18:10 UTC | |
by plvicente (Novice) on May 06, 2021 at 18:12 UTC | |
by marto (Cardinal) on May 06, 2021 at 18:15 UTC | |
by plvicente (Novice) on May 06, 2021 at 18:26 UTC | |
by Bod (Parson) on May 06, 2021 at 22:28 UTC | |
|