Re: Directly changing To & From field in the header

Mark Overmeer <[email protected]> Mon, 7 Feb 2005 22:55:46 +0100
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Vic Norton ([email protected]) [050207 21:10]:
> I copied your suggestion directly into the script I presented, 
> Gilles. I get exactly the same error message.
>     /Library/Perl/5.8.1/Mail/Message/Head/Complete.pm: Line 172:
>     Can't call method "clone" without a package or object reference

What version of MailBox are you running?  In my version, the clone is
on line 198...

> The problem came up when I was tried to create a plain text mail 
> message and then, in a loop, change the to-field and body before 
> sending it out. So far I've been totally unsuccessful in doing this. 
> Perhaps the way I had been doing it before was better anyway. Then I 
> would just create a new head, new body, and new message on each 
> iteration of the loop.
> 
> >$msg->head->reset( 'To', Mail::Message::Field->new( 'To', "\"Vic\" 
> ><norton\@dacor.net>") ) ;

This certainly should work.  I have tried it out.
Simpler is
  $msg->head->set(To => '"Vic" <[email protected]>' ) ;

An other way to get your task to work is:

  my $msg = Mail::Message->build(....);
  $msg->send(to => '"Vic" <[email protected]>' );

The destination will not be visible in the sent headers, but plays its
role in the SMTP protocol.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net