Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: sendmail on windows- unique location

by antirice (Priest)
on Nov 03, 2005 at 04:53 UTC ( [id://505220]=note: print w/replies, xml ) Need Help??


in reply to sendmail on windows- unique location

Hmmm, I just tried using that sendmail program with Mail::Mailer and finally got it to work. Please note that getting it to work isn't easy and requires you to edit Mail::Mailer's source to get it to work properly on windows. Also, please be certain that your perl is 5.6.1 or later.

First, here's my test script:

#!/usr/bin/perl -l BEGIN { $ENV{'PERL_MAILERS'} = 'sendmail:c:\sendmail.exe'; } use Mail::Mailer "sendmail"; my $m = Mail::Mailer->new(); $m->open({qw( From someone@somewhere.com To someone@someotherplace.com Subject hey )} ); print $m "Hi"; $m->close;

Please make certain you're putting '.exe' at the end of the executable or it'll complain that it can't find the executable. Now we have to work around a problem with Mail::Mailer. Unfortunately, it uses open($self,"|-") which, if you've read perldoc perlfork, isn't implemented on windows yet. However, there's a workaround. You'll need to add the following code to Mail::Mailer's source (preferably towards the end):

sub pipe_to_fork { my $parent = shift; pipe my $child, $parent or die; my $pid = fork(); die "fork() failed: $!" unless defined $pid; if ($pid) { close $child; } else { close $parent; open(STDIN, "<&=" . fileno($child)) or die; } $pid; }

You will then need to go to line 269 and change open($self,"|-") to pipe_to_fork($self).

Once you've done that, it should work. If it doesn't please reply below.

Replies are listed 'Best First'.
Re^2: sendmail on windows- unique location
by Anonymous Monk on Nov 03, 2005 at 23:41 UTC
    Thanks! I would not have ever cought the windows Mail::Mailer error.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://505220]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-18 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found