Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: can't get mailx to send from within a script

by gellyfish (Monsignor)
on Aug 17, 2006 at 12:10 UTC ( [id://567902]=note: print w/replies, xml ) Need Help??


in reply to can't get mailx to send from within a script

Doesn't mailx need some input on it's STDIN, like the message for instance? I think you need to do something like (untested) :

open MAILX,'|/bin/mailx -s "hello" john@work.com' or die $!; print MAILX 'Your message here'; close MAILX or die "mailx: $! $?";

I would however recommend using another mechanism to send mail in your program, not limited to piping directly to sendmail or using a module such as Email::Send

/J\

Replies are listed 'Best First'.
Re^2: can't get mailx to send from within a script
by Adrian (Initiate) on Aug 17, 2006 at 13:51 UTC
    Gellyfish,

    not sure why the other suggestions didn't work, but yours did so that's what I went with.

    As it happens I needed to email the contents of a file and found this to work :

    $file="/tmp/output.txt";

    my $text = do { local( @ARGV, $/ ) = $file ; <> } ;

    open MAILX,'|/bin/mailx -s "Output" John@work.com' or die $!;

    print MAILX $text;

    close MAILX or die "mailx: $! $?";

    many thanks to all who contributed, Ad

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-25 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found