Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Multiple Recipients using SMTP

by ghouse (Novice)
on Dec 23, 2004 at 15:44 UTC ( [id://417129]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, We are working on perl script in our application which is sending mails to many users We are using Net::SMTP We are using an array to store the multiple recipients and send the mails But in the e-mail sent, we are not able to see all the email address of the recipients in To/Cc field.
my @cclist = ('abc\@yahoo.com','bfgh\@hotmail.com','rew\@rediff.com'); my @ToAddress = ('abc\@yahoo.com','bfgh\@hotmail.com','rew\@rediff.com +'); # Create a new multipart message: $MIMEEntity = build MIME::Entity From => $FromAddress, 'Reply-To' => $ReplyToAddress, To => @ToAddress, CC => @cclist, Subject => $MailSubject, Notify => 'SUCCESS,FAILURE,DELAY', Type => 'multipart/mixed'; $NetSMTP->mail($FromAddress) or die "ERROR calling SMTPmail, stopped"; $NetSMTP->to(@ToAddress) or die "ERROR calling SMTPmail, stopped"; $NetSMTP->cc(@cclist) or die "ERROR calling SMTPmail, stopped";
How do we fix this

2004-12-23 Janitored by Arunbear - added code tags, as per Monastery guidelines

Replies are listed 'Best First'.
Re: Multiple Recipients using SMTP
by maa (Pilgrim) on Dec 23, 2004 at 15:49 UTC
    Try not escaping the @ - you're using single quotes, after all.
Re: Multiple Recipients using SMTP
by muntfish (Chaplain) on Dec 23, 2004 at 17:06 UTC

    When you build the MIME::Entity, I don't think you can do

    To => @ToAddress, CC => @cclist,

    as I suspect the arrays will flatten into the parameter list. You should probably do something like:

    To => join(',', @ToAddress), CC => join(',', @cclist),

    or maybe you can pass an array reference (not familiar with what MIME::Entity can accept).

    Also the advice to not escape @ in single-quoted strings sounds good to me.


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
      Thank you for valuable tip .. It's working now

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://417129]
Approved by edan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found