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? | [reply] |
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
| [reply] [d/l] |
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. | [reply] [d/l] |
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.
| [reply] [d/l] |
I know this is old, but thanks!!! This was the problem. Thanks for posting this4 years ago!
| [reply] |
Yes, thanks for that suggested fix to Gmail.pm! It was line 57 in my copy. This fixed my problem!
| [reply] |