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


In reply to send mail cgi by plvicente

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.