I have my following code below to send notifications, newsletters to my registered customers and its working well

my Question is that, is it really efficient and effective to send out mails to over 100k customers emails

 CGI CODE
#!/usr/bin/perl -wT use strict; use warnings; use CGI qw/:standard/; print "Content-type: text/html\n\n"; print <<HTML; <!doctype html> <html lang = "en"> <head> <meta charset = "utf-8"> <title>mail sending with progressbar-jquery-ajax-</title> <link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightn +ess/jquery-ui.css" rel = "stylesheet"> <script src = "https://code.jquery.com/jquery-1.10.2.js"></scrip +t> <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js">< +/script> <style> .ajax-loader { display: inline-block; width: 20px; height: 20px; border: 8px solid #204d74; border-right-color: transparent; border-radius: 50%; animation: spin 1.3s linear infinite; } \@keyframes spin { from { transform: rotate(0deg); opacity: 0.3; } 50% { transform: rotate(180deg); opacity: 1.0; } to { transform: rotate(360deg); opacity: 0.3; } } </style> <script> \$(document).ready(function () { \$("#Submit").click(function(event) { if (\$("form input[name='sub']").val() == "") { \$('#error').text("Subject Required"); return false; } if (\$("form textarea[name='msg']").val() == "") { \$('#error').text("Message Required"); return false; } Execute(); \$('#error').hide(); \$('#progress_start').show(); }); function Execute(){ \$.ajax({ xhr: function() { var xhr = new window.XMLHttpRequest(); //Upload progress xhr.upload.addEventListener("ajax-loader", function(evt){ if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; //Do something with upload progress console.log(percentComplete); } }, false); //Download progress xhr.addEventListener("ajax-loader", function(evt){ if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; //Do something with download progress console.log(percentComplete); } }, false); return xhr; }, type: 'POST', url: 'mail.pl', data: { 'sub': \$("input[name='sub']").val(), 'msg': \$("textarea[name='msg']").val() }, success: function(res){ \$('#progress_start').hide(); \$('#Response').html(res.msg); }, error: function() { alert("Failed To send Message"); } }); }; }); </script> </head> <body> <br> <form method="post"> <input type="text" id="sub" name="sub" placeholder="Subject"><br><br +> <textarea id="msg" name="msg" placeholder="Message"></textarea><br>< +br> <input type="button" id="Submit" value="Submit"> </form> <div id='progress_start' style='display:none'> <p>Running the task<span class="ajax-loader"></span></p> </div> <div id="Response"></div> <div id="error"></div> </body> </html> HTML
 Mail.pl code
my $sub = $Cgi->param("sub"); my $msg = $Cgi->param("msg"); my $Response; if ($sub) { my $select_emails = $dbh->prepare("SELECT DISTINCT email FROM testuser +"); $select_emails->execute(); my $records = $select_emails->fetchall_arrayref; my @to; for my $em ( @$records ) { push @to, @$em; } for my $recipient(@to) { mail($recipient); } sub mail { my $recipient = shift; my $smtpserver = 'smtp.xxxxxx.com'; my $smtpport = 587; my $smtpuser = 'xxxxx'; my $smtppassword = 'xxxxxx'; my $transport = Email::Sender::Transport::SMTP->new({ host => $smtpserver, ssl => 'starttls', port => $smtpport, sasl_username => $smtpuser, sasl_password => $smtppassword, }); my $email = Email::Simple->create( header => [ To => $recipient, From => 'xxxxx@xxxx.com', Subject => $sub, 'Content-Type' => 'text/html', ], body => $msg, ); sendmail($email, { transport => $transport }); $Response = "Done sending"; } my $json = encode_json( { msg => $Response } ); print $Cgi->header( -type => 'application/json' ),$json; } $dbh->disconnect;

In reply to Mail sending by frank1

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.