in reply to Where is the Email coming from?

If I am understanding you correctly, you are asking how to come up with a correct value, 'me@here.com' for the From argument below:
%mail = ( To => 'you@there.com', From => 'me@here.com', Message => "This is a very short message" ); sendmail(%mail) or die $Mail::Sendmail::error;

I do not think it is possible to do this reliably every time - although another monk may well correct me on that. How to get that email address will differ from environment to environment.

I am lucky, since in my environment users' email addresses take the form firstname.lastname@domain.com, so I can use the Unix `ypcat passwd` to find their full name, and construct their email address from that.

If this is not possible, then perhaps a configuration file that maps userids to full email addresses is maybe the easiest (with all of its inherent maintenance headaches).