in reply to Multiple Recipients in email

The gmail mailserver is telling you "no valid recipients", meaning it won't let you do that.

Replies are listed 'Best First'.
Re^2: Multiple Recipients in email
by nephorm (Novice) on Jan 24, 2009 at 08:07 UTC
    That's odd, because I can send email to multiple recipients (and CCs, and BCCs) through standard email clients connecting to gmail through smtp... So what are those clients doing that I am not?
      Something or other :) Copy this and turn on Debug. http://cpansearch.perl.org/src/LBROCARD/Email-Send-Gmail-0.33/lib/Email/Send/Gmail.pm
      mostly cribbed from Email::Send::SMTP sub send { my ( $class, $message, @args ) = @_; my %args = @args; my ( $username, $password ) = @args{qw[username password]}; my $smtp = Net::SMTP::SSL->new( 'smtp.gmail.com', Port => 465, Debug => 0, ) || croak( 'Email::Send::Gmail: error connecting to server smtp.gmail.com +'); $smtp->auth( $username, $password ) or croak("Email::Send::Gmail: error authenticating username $user +name"); my @bad; eval { my $from = $class->get_env_sender($message); $smtp->mail($from) || croak("Email::Send::Gmail: error sending 'from' $from") +; my @to = $class->get_env_recipients($message); my @ok = $smtp->to( @to, { SkipBad => 1 } ) || croak("Email::Send::Gmail: error sending 'to' @to"); if ( @to != @ok ) { my %to; @to{@to} = (1) x @to; delete @to{@ok}; @bad = keys %to; } croak("Email::Send::Gmail: no valid recipients") if @bad == @t +o; }; croak($@) if $@; croak("Email::Send::Gmail: error sending data") unless $smtp->data( $message->as_string ); $smtp->quit || croak("Email::Send::Gmail: error sending 'quit'"); return 1; }
      Net::SMTP
        That was a good point, so I attempted to do what you suggested. Strangely enough... it didn't give the error when I called my own version of that function.

        This left the Bcc problem I was having as unresolved, and when I added Bcc recipients via the header command, I got emails to all listed, but the list of recipients was visible to everyone. So, looking back through the Net::SMTP documentation, I saw that email::send::gmail does not a make call like:

        $stmp->bcc(@recips,{SkipBad=>1});
        and instead stuffs everything into the "to" recipients.

        Long story short(er), I rewrote the send routine to properly parse out the bccs, remove them from the header, etc, and everything seems to be working, now.

        Thanks for the help.

Re^2: Multiple Recipients in email
by rpoyner (Initiate) on Sep 09, 2009 at 16:01 UTC
    The "no valid recipients" message is coming from a croak statement in the Email::Send::Gmail module.

    The problem as is turns out is an error in the module code that varifies the recipient addresses. The current version of the module finds an error with multiple addresses when there is none.

    The fix was simple. Just needed a pair of parentheses around line 57:

    <<< my @ok = $smtp->to( @to, { SkipBad => 1 } ) >>> (my @ok = $smtp->to( @to, { SkipBad => 1 } ))
    I have sent an email to the maintainer to this effect. Hopefully he will find time to make the change.
      I know this is old, but thanks!!! This was the problem. Thanks for posting this4 years ago!
      Yes, thanks for that suggested fix to Gmail.pm! It was line 57 in my copy. This fixed my problem!