Re: [siesta-dev] problem with Email::Valid in Siesta::Message

[prev] [thread] [next] [lurker] [Date index for 2002/10/10]

From: Richard Clamp
Subject: Re: [siesta-dev] problem with Email::Valid in Siesta::Message
Date: 11:02 on 10 Oct 2002
On Thursday, Oct 10, 2002, at 09:45 Europe/London, Simon Wistow wrote:
> On Thu, Oct 10, 2002 at 09:34:36AM +0100, Roger Burton West said:
>> Side note: Is there any reason we don't use Mail::Address directly
>> instead of Email::Valid (which depends on it)? That _will_ accept an
>> address of the form that's causing problems, without complaint.

> I have no idea. I think we'd been drinking at the time that that
> particular piece of code got written. I remember finding the module and
> suggesting it with a frown on my face and Richard not being
> particularly happy with it.

I disremember - I think maybe it was another module you'd found, but 
*shurg*

This is what I've patched:

--- Message.pm	20 Sep 2002 20:32:05 -0000	1.30
+++ Message.pm	10 Oct 2002 09:55:34 -0000	1.31
@@ -3,7 +3,7 @@
  use strict;

  use Siesta;
-use Email::Valid;
+use Mail::Address;
  use Mail::Internet;
  use base 'Mail::Internet';
  use Storable qw(dclone);
@@ -17,7 +17,7 @@
      if (@_) {
          $self->head->replace( 'To', shift );
      }
-    Email::Valid->address( $self->head->get('To') );
+    map { $_->address } Mail::Address->parse( $self->head->get('To') );
  }

  sub from {
@@ -25,7 +25,7 @@
      if (@_) {
          $self->head->replace( 'From', shift );
      }
-    Email::Valid->address( $self->head->get('From') );
+    map { $_->address } Mail::Address->parse( $self->head->get('From') 
);
  }

  sub subject {

And there's a t/03message.t that exercises it.

>> I agree with Gavin that there's no point in testing for an error
>> condition if we aren't going to handle it.
>
> This is true. In this case I suspect that the thing to do is something
> like

I've got out of of step with my email but this sounds backwards - if an 
error is possible it should be handled.

> $mail->from($args{from} || $mail->to() || $list->admin());
>

Urm - err.  I think it should really be:
$mail->reply(from => $list->confirm_address);, thus taking the failure 
to identify ->to out of the equation.

-- 
Richard Clamp <richardc@xxxxxxxxx.xxx>


There's stuff above here

Generated at 13:56 on 01 Jul 2004 by mariachi 0.52