Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

kellan (905)

kellan
  (email not shown publicly)
http://laughingmeme.org/

Journal of kellan (905)

Friday March 01, 2002
02:56 AM

Mail::Mailer, and the frustrating From header

[ #3208 ]
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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • 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 ended up giving up and using Mail::Sendmail or MIME::Lite but its good to know a fix.