Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) 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.

Mail::Util docs:

Return a guess at the current users mail address. The user can force the return value by setting $ENV{MAILADDRESS}

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:

$self->SUPER::set_headers({ From => "<" . mailaddress() . ">", %$hdrs, 'X-Mailer' => "Mail::Mailer[v$Mail::Mailer::VERSION] Net::SMTP +[v$Net::S\ MTP::VERSION]"

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!

In reply to Re: How do I rewrite mail headers using Mail::Send? by djantzen
in thread How do I rewrite mail headers using Mail::Send? by c

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2021-09-27 04:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found