Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

am having problem with my send mail script. first it cant show progress when send starts. second cant send to multiple receipts

i appreciate for correction

#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI; use MIME::Lite; use CGI::ProgressBar qw/:standard/; $| = 1; # Do not buffer output my $CGI = CGI->new(); my $from_email = $CGI->param("from_email"); my $from_name = $CGI->param("from_name"); my $subject = $CGI->param("subject"); my $receipts = $CGI->param("receipts"); my $message = $CGI->param("message"); # Newline format. send message to each email listed my $output = join "\n", split " ", $receipts; if ($from_email, $from_name, $subject, $receipts, $message) { my $msg = MIME::Lite->new( # From Name: John Deo And Sent From Email: johndeo@mail.com From => "$from_name <$from_email>", To => $output, Subject => $subject, Data => $message ); # Support HTML Message $msg->attr("content-type" => "text/html"); $msg->send; if ($msg) { # if mail starts sending print progress_bar( -from=>1, -to=>100 ); for (1..100){ print update_progress_bar; # Print ProgressBar $progressbar_html = qq{<div class="box"> <div id="progressbar"> <div></div> </div> <div class="text">Sending... 1%</div> </div> }; sleep 1; } print $response = "Message Sent Successfully"; exit; } if(!$msg) { print $response = "Message Failed To Send"; } } print "Content-type: text/html\n\n"; print <<START_HTML; <!DOCTYPE html> <html> <head> <title>Simple Mailer</title> <style type="text/css"> .box { border-radius: 10px; padding: 25px; background-color: rgba(51, 51, 51, 0.96); text-align: center; } #progressbar { border: 3px solid #fff; border-radius: 20px; padding: 2px; } #progressbar > div { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; background-color: #fff; width: 1%; height: 18px; border: 1px solid rgba(0, 0, 0, 0); border-radius: 20px; } .text { color: #fff; margin-top: 15px; font-size: 21px; font-weight: bold; } </style> </head> <body> <form method="post"> <label>From Email <input type="text" name="from_email" /> <br /> <br /> From Name <input type="text" name="from_name" /> </label> <p> <label>Subject <input type="text" name="subject" /> </label> </p> <p> <label>Receipts <textarea name="receipts"></textarea> </label> </p> <p> <label>message <textarea name="message"></textarea> </label> </p> <p> <label>Send <input type="submit" value="Submit" /> </label> </p> </form> <p>&nbsp;</p> $progressbar_html <p>$response</p> </body> </html> START_HTML

In reply to send mail by bigup401

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-10-25 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?