|We don't bite newbies here... much|
Re: How do I rewrite mail headers using Mail::Send?by djantzen (Priest)
|on Jun 25, 2002 at 04:13 UTC||Need Help??|
I ran into this problem just the other day. Under the covers all Mail::Send does is pass the header's hash to a Mail::Mailer::* subclass and then to a platform specific program like sendmail.
Check to see if the exact subclass of Mail::Mailer you're using is smtp. If so, it's using Mail::Util::mailaddress to set the 'From' value in the method set_headers.
Update: This is the code for set_headers, which I just noticed overwrites the value returned by mailaddress with the value of 'From' (if specified) in the headers:
I should note that although I encountered this problem a couple days ago, I haven't yet solved it! ;)
UPDATE: Aha! I think I've got it. I was mistaken in thinking that sendmail was the mail program it was defaulting to. In fact, it was running mailx. Now, you can force it to use sendmail by passing the string 'sendmail' when you call Mail::Send::open. Doing so will (probably) enable you to set the 'From' value successfully.
I believe that the reason the 'From' header gets changed has to do with /etc/mail/mailx.rc which (on my system (Solaris 8)) lists quite a number of allegedly "uninteresting" headers to ignore. I don't see 'From' specifically, but there are a couple of other likely candidates there. So, I think it wipes out the value submitted via Mail::Send/Mailer and resets it with the 'username@hostname' combination.
Whew! Sorry for the stream of consciousness answer -- I just kept thinking I'd figured out the problem!