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

am having above script to send announcement to my clients in db, but my problem when i send message is delivered to all. and there is no problem. but it appears to customers emails like this

To: 2c@talktalk.net, 3c@talktalk.net, 4c@talktalk.net, 5c@talktalk.net +, 5c@talktalk.net, 5c@talktalk.net, 5c@talktalk.net

it shows all recipients. i only want to show single email for actual receiver like

To: email_owner@show_alone.com

not all recipients

here is my code

$getemails = $DBH->prepare("SELECT DISTINCT EMAIL FROM USERS"); $getemails->execute(); $db_emails = $getemails->fetchall_arrayref; $emails = join ',',map{$_->[0]}@$db_emails; $TO = $emails; $FROM = 'myeamil@email.com'; $SUBJECT = 'hey'; $MESSAGE = " Sup "; $MSG = MIME::Lite->new( From => $FROM, To => $TO, Subject => $SUBJECT, Data => $MESSAGE ); $MSG->send;

Replies are listed 'Best First'.
Re: send mail
by stevieb (Canon) on Apr 03, 2019 at 23:14 UTC

    After a *very* cursory glance, Mime::Lite shows that there are fields other than To.

    Bcc (ie. Blind carbon copy) is what you want.

    When in doubt, read the documentation (RTFM!!).

    So, set To to yourself or blank, and dump all others into the Bcc field.

    Besides that, don't use ALL CAPS for variable names, unless they are constants. It's a poor practice to use all upper-case variable names like you have. This is consistent in Perl, and nearly all other programming languages.

    Update: ...and where's your use strict; and use warnings;? Is this just a code snip where your variables have already been declared, or do you simply not pay attention to what's been presented to you time-and-time again?

      thanks, it works with bcc and blank to

        You're very welcome.

        Note though, that this is the last post I'll help you with if you don't start following common best practices and/or advice that you've been made aware of repeatedly.