logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Directly changing To & From field in the header: msg#00010

Subject: Re: Directly changing To & From field in the header
Thanks for your note, Mark. I'm sorry. I may have screwed something up. Things are working now.

I am using Mail::Message version 2.057. Your
    $msg->head->set(To => '"Vic" <norton@xxxxxxxxx>' ) ;
is just the idea I was looking for.

My real question is this. Suppose you have a loop. You send out one single-part plain-text message in each iteration of the loop. The header of each message is the same except for a couple of fields. The body changes slightly depending on who you are sending the mail to.

Should you create a new mail-message object that starts with the right head and body in each iteration of the loop? Or should you create an initial mail-message ahead of the loop and adjust it with each iteration?

I know how to do the former. I don't know how to do the latter. And I don't know whether adjusting a message-object (if I could figure out how to adjust it) would be any more efficient than creating a new message-object in each iteration.

Regards,

Vic

At 10:55 PM +0100 2/7/05, Mark Overmeer wrote:
* Vic Norton (vic@xxxxxxxxxxx) [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" <norton@xxxxxxxxx>' ) ;

An other way to get your task to work is:

  my $msg = Mail::Message->build(....);
  $msg->send(to => '"Vic" <norton@xxxxxxxxx>' );

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
       Mark@xxxxxxxxxxxx                          solutions@xxxxxxxxxxxx
http://Mark.Overmeer.net                   http://solutions.overmeer.net


--
*------* http://www.ridehsta.com
|  Vic Norton      2005 R1200GS    HSTA 5992  DOD 43403
| (419)353-8399    1997 KLR650     STOC 037   AMA 594102
*------* http://vic.norton.name/moto




<Prev in Thread] Current Thread [Next in Thread>