I send periodic emails to a variety of clients and the addresses change with the variety. I currently a form for the email composition and address the email to "undisclosed recipients (my email address) with BCC's going to the individual clients. I use the following code to accomplish that.

##sendmail_email.pl #!C:/Perl/bin/perl -w use CGI qw(:standard); use HTML::Entities; use Mail::Sendmail 0.79; # doesn't work with v. 0.74! my $Recipient=param('Recipient'); my $Sender=param('Sender'); my $bcc_list=param('bcc_list'); my $Subject=param('Subject') my $Message = param ('Message'); $html = <<END_HTML; <p>$Message</p><p><font size="2"> END_HTML my %mail; $mail{Smtp}="smtp.sendgrid.net"; $mail{Port}=587; $mail{Auth}={user=>"Milt1", password=>"XXXXXXX", method => "LOGIN", re +quired => 1}; $mail{To}=$Recipient; $mail{From}= $Sender; $mail {bcc}="$bcc_list"; $mail{Subject}=$Subject; $mail{'content-type'} = 'text/html; charset="iso-8859-1"'; $mail{body} = <<END_OF_BODY; <html>$html</html> END_OF_BODY sendmail(%mail) || print "Error: $Mail::Sendmail::error\n"; &redirect; sub redirect { print header(), start_html; print "Your Message Was Sent\n\n"; } exit;

I want to address each client individually by name and not utilize BCC's. Can this be done without reading from a 'file' saved on the server or can it be done by pasting the list into text area on the form named "Email_List", input into the cgi as: my $Email=param ('Email_List'); put into and array and read with a foreach loop? Something like this:

my@=<$Email>; if (@a) { foreach $Address(@a) { $Recipient=$Address; } }

I haven't been able to get any of several trials to work. Any help/suggestions will be sincerely appreciated. Thanks!


In reply to Email To A List Of Addresses by Milti

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.