Skip Menu |

This queue is for tickets about the Mail-SendEasy CPAN distribution.

Report information
The Basics
Id: 47831
Status: open
Priority: 0/
Queue: Mail-SendEasy

People
Owner: Nobody in particular
Requestors: dprelec [...] oglasnik.hr
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: mail check too strict, pt.2
Date: Mon, 13 Jul 2009 13:24:45 +0200 (CEST)
To: bug-Mail-SendEasy [...] rt.cpan.org
From: "Darko Prelec" <dprelec [...] oglasnik.hr>
Hi! Machine info: - Perl version is 5.8.8 - GNU/Linux 2.6.18-6-amd64 - OS: Debian 4.0 - module_info Mail::SendEasy Name: Mail::SendEasy Version: 1.2 Directory: /usr/local/share/perl/5.8.8 File: /usr/local/share/perl/5.8.8/Mail/SendEasy.pm Core module: no Description: Version 1.2 of Mail::SendEasy Perl module has another simple bug in email check routine. It reports valid email addresses as "Invalid recipient". Fix: The bug can be located on the line 450 in the Mail/SendEasy.pm file, subroutine _format(), and here's the patch: --- SendEasy.pm 2009-07-13 13:19:39.000000000 +0200 +++ SendEasy.pm.fixed 2009-07-13 13:16:14.000000000 +0200 @@ -447,7 +447,7 @@ my $stat = 1 ; if ($mail !~ /^[\w\.-]+\@localhost$/gsi) { - if ($mail !~ /^[\w\.-]+\@(?:[\w-]+\.)*?(?:\w+(?:-\w+)*)(?:\.\w+)+$/ ) { $stat = undef ;} + if ($mail !~ /^[\w\.-]+\@(?:[\w-]+\.)*?(?:\w+(?:[\w-]+)*)(?:\.\w+)+$/) { $stat = undef ;} } elsif ($mail !~ /^[\w\.-]+\@[\w-]+$/ ) { $stat = undef ;}
Here's an example where valid email address is detected as invalid: use strict; use warnings; use Mail::SendEasy; my @emails = qw( user@foo-bar.net uset@foo--bar.net ); for my $email (@emails) { if (!Mail::SendEasy::_check_emails($email)) { print "Not ok $email\n"; } }
Subject: mail check too strict, pt.3
Hi, I am also having some trouble getting legitimate email address through the _format routine. But I must say this a great Module, nice work Graciliano :) I have installed the module locally and made some of my own minor modifications. It seems easier to use Ricardo Signes's very nice Email::Valid module to do the validation: Here is the diff output from 1.2 of Mail/SendEasy.pm and the changes I have made: Show quoted text
> use Email::Valid ;
426a428 Show quoted text
>
433c435 < if (! &_format($mails_i) ) { $ER = "Invalid recipient: $mails_i" ; return( undef ) ;} --- Show quoted text
> if (! Email::Valid->address($mails_i) ) { $ER = "Invalid
recipient: $mails_i" ; return( undef ) ;} 438,457d439 < ########### < # _FORMAT # < ########### < < sub _format { < if ( $_[0] eq '' ) { return( undef ) ;} < < my ( $mail ) = @_ ; < < my $stat = 1 ; < < if ($mail !~ /^[\w\.-]+\@localhost$/gsi) { < if ($mail !~ /^[\w\.-]+\@(?:[\w-]+\.)*?(?:\w+(?:-\w+)*)(?:\.\w+)+$/ ) { $stat = undef ;} < } < elsif ($mail !~ /^[\w\.-]+\@[\w-]+$/ ) { $stat = undef ;} < < return 1 if $stat ; < return undef ; < } < In a nutshell: 1) Add a use statement for Email::Valid 2) Remove the _format sub 3) Replace the call to _format with a call to Email::Valid->address Cheers, Cam On Mon Jul 13 07:44:20 2009, dprelec wrote: Show quoted text
> Here's an example where valid email address is detected as invalid: > > use strict; > use warnings; > use Mail::SendEasy; > > my @emails = qw( > user@foo-bar.net > uset@foo--bar.net > ); > > for my $email (@emails) { > if (!Mail::SendEasy::_check_emails($email)) { > print "Not ok $email\n"; > } > } >