Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Mail::Send and Bcc revealed

by Kozz (Friar)
on Jun 03, 2004 at 20:20 UTC ( #360464=perlquestion: print w/ replies, xml ) Need Help??
Kozz has asked for the wisdom of the Perl Monks concerning the following question:

Most wise monks: I am using the module Mail::Send in a particular script because it is the best available on this server. When sending emails, I am getting a rather interesting problem, and am not sure how to deal with it.
$msg = new Mail::Send; $msg->add('From', $rs->{'em_from'} ); $msg->to( $rs->{'em_to'} ); $msg->cc( $rs->{'em_cc'} ); $msg->bcc( $rs->{'em_bcc'} ); $msg->subject( $rs->{'em_subject'} ); # print the message to mail it # $fh = $msg->open(); $fh = $msg->open('sendmail'); # explicit $rs->{'em_body'} =~ s/\n/\r\n/sg; # convert line-endings for windows m +achines. print $fh $rs->{'em_body'}; $fh->close(); # completes message and sends it
The mail gets sent just fine. However, I have a comma-delimited list of recipients in $rs->{'em_bcc'}, and the first address in the bcc list becomes part of a header:
X-Final-To: bccaddress@site.com
Obviously I chose BCC for a reason, but here it's not working. Does this have to do with the order in which I am adding the headers? I don't want any BCC addresses showing up in any of the headers. I've tried setting the to, cc, etc fields when creating the new Mail::Send object too, but it all works the same of course.

Is this just a sendmail thing that I've never experienced before?

Thanks for your help.

Comment on Mail::Send and Bcc revealed
Select or Download Code
Re: Mail::Send and Bcc revealed
by xorl (Deacon) on Jun 03, 2004 at 20:38 UTC
    A work around would be to have the first address in the list be one you don't mind showing up in the headers. As for what is causing this problem... I'm sorry but I don't know. I usually do something like:
    open(MAIL, "|/usr/lib/sendmail -oi -t") || die "Can't open sendmail: $ +!"; print MAIL <<MESSAGE; To: $email Bcc: $bcc1, $bcc2 Subject: $subject This is an automagically generated message, please do NOT reply to it. MESSAGE print MAIL "More text goes here"; close(MAIL);
    EDIT: you could use a foreach loop to add enough Bcc: addresses.
Re: Mail::Send and Bcc revealed
by hsinclai (Deacon) on Jun 03, 2004 at 22:17 UTC
    I was curious what values in %rs looks like.

    By chance did you try enclosing the string of comma-separated email recipients within single quotes inside the hash value?

    That might keep the string together, and make the bcc field get respected entirely..
Re: Mail::Send and Bcc revealed
by Kozz (Friar) on Jun 04, 2004 at 16:32 UTC

    Well, I've tried enclosing the bcc recip list in single quotes, and also have tried just opening a pipe to sendmail as suggested, and also combining them, but they all result in an X-Final-To header.

    Conclusion: I blame it on the host for running Sendmail 8.9.3 which is (as of this writing) over 5yrs old (and getting that upgraded will be like pulling teeth). Argh. The host shall remain nameless.

    Thanks to you who've reviewed this question and offered suggestions.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-07-10 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (199 votes), past polls