Mail::Mailer, and the frustrating From header

kellan on 2002-03-01T06:56:17

I wrote up a little script using Mail::Send. Mail::Send doesn't explicity have a from() method, but $msg->set('From', 'quxx@example.com') works fine. Or at least it worked fine on my laptop. However when I moved the same script to my server, I mail was now being sent out from 'apache@protest.net'.

I was puzzled. I tried making apache a trusted Exim user, double checked that example.com was acknowledged as a local domain, etc, etc. In mounting frustration I was tempted to throw it all out, and revert to the bad old days of talking to sendmail (well Exim in sendmail clothing) directly.

Then it hit me, Mail::Send is using Mail::Mailer under the covers, Mail::Mailer first attempts to send mail out using the unix mail program, and then falls back on using sendmail.

My laptop doesn't have mail installed, the server does.

So if I change: $fh = $msg->open(); # $msg is an instance of mail send
to
$fh = $msg->open('sendmail');

Now everything works like a charm.

I mention this here, because surprisingly a quick google search turned up no mentions of anyone ever running into a similiar problem. So hopefully the next person (assuming anyone else is as slow) will stumble across this.


Other behaviour

arhuman on 2002-03-01T08:32:02

So if I change: $fh = $msg->open(); # $msg is an instance of mail send
to
$fh = $msg->open('sendmail');


I had to do the same thing to make the cpantest work on some of my boxes the symptom was that the header was screwed :
The subject was thrown out of the Header and appeared in the body prefixed by '~s'.
(Thus making it an invalid bounced message (no subject))

I had the same problem

autarch on 2002-03-01T14:34:41

I ended up giving up and using Mail::Sendmail or MIME::Lite but its good to know a fix.

Re:I had the same problem

digitaltrickery on 2002-05-16T09:19:25

I was going mad over this - thanks for the fix. I guess I should've realised it was using mail sooner.