Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

send mail

by bigup401 (Pilgrim)
on Feb 11, 2019 at 21:06 UTC ( #1229766=perlquestion: print w/replies, xml ) Need Help??

bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

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: 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

Replies are listed 'Best First'.
Re: send mail
by stevieb (Canon) on Feb 11, 2019 at 22:23 UTC

    You've shown a lot of things here that are irrelevant.

    Produce code for each problem at a time. 1) email, 2) the status piece.

    Get rid of all the HTML/CSS etc until these two key items are sorted.

    Also, you're gaining less and less credibility by continuing to ask questions here without utilizing the recommendations that have been presented to you in the past: use warnings;, use strict;... where are those for example?

      > where are those for example?
      Warnings is on the shebang line.
Re: send mail
by poj (Abbot) on Feb 12, 2019 at 18:18 UTC

      well, i saw this cgi::progressbar example before. and also some samples. but i think mine is so different the problem with mine it has different css/js and am looking forward when the send mail command is pressed it should start progressing

Re: send mail
by Lotus1 (Vicar) on Feb 13, 2019 at 16:04 UTC

    bigup401 wrote:

    # Newline format. send message to each email listed my $output = join "\n", split " ", $receipts;

    I don't think "Newline format" is a valid way to make a list of email recipients for MIME::Lite. I've always used comma separated lists and all the examples I've seen are like that. Perhaps you could consider making a small test program that just sends a test email to two addresses. After you get that working then make small test programs for the other parts of this you need to accomplish.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: send mail
by Anonymous Monk on Feb 12, 2019 at 14:55 UTC
    Great script for spammers to use. You should stop.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1229766]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-11-27 15:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found