Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Trouble piping output of command to input of SENDMAIL

Jul
68
1
Is this WAD, or is this a bug? I'm having trouble piping the console output of a command/file to the console input of SENDMAIL

Code:
[100%] D:\Users\Mark\Documents\test 4\PipingTest>alias sendmail
*sendmail /ssl=2

[100%] D:\Users\Mark\Documents\test 4\PipingTest>sendmail "[email protected]" "Test 1" This is test #1

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo This one worked as expected
This one worked as expected

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo Trying to pipe console output to console input of SENDMAIL
Trying to pipe console output to console input of SENDMAIL

[100%] D:\Users\Mark\Documents\test 4\PipingTest>dir

 Volume in drive D is DATA         Serial number is c008:8942
 Directory of  D:\Users\Mark\Documents\test 4\PipingTest\*

12/05/2022  10:14         <DIR>    .
12/05/2022  10:14         <DIR>    ..
                   0 bytes in 0 files and 2 dirs
     225,415,217,152 bytes free

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo foo > test.txt

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo bar >> test.txt

[100%] D:\Users\Mark\Documents\test 4\PipingTest>type test.txt
foo
bar

[100%] D:\Users\Mark\Documents\test 4\PipingTest>type test.txt | sort
bar
foo

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo Sort command takes output of TYPE and uses it as input to SORT, just as I expected
Sort command takes output of TYPE and uses it as input to SORT, just as I expected

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo Now to pipe into SENDMAIL
Now to pipe into SENDMAIL

[100%] D:\Users\Mark\Documents\test 4\PipingTest>type test.txt | sendmail "[email protected]" "Test 2" @con:
This is not successful.
Have to put CTRL-Z to end
^Z

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo SENDMAIL did not take the contents of test.txt and instead wanted me to type text on the keyboard and terminate with CTRL-Z
SENDMAIL did not take the contents of test.txt and instead wanted me to type text on the keyboard and terminate with CTRL-Z

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo stupid | sendmail "[email protected]" "Final Test" @con:
This is really stupid!
^Z

[100%] D:\Users\Mark\Documents\test 4\PipingTest>echo Piping the output of another command into SENDMAIL doesn't seem to work either
Piping the output of another command into SENDMAIL doesn't seem to work either

[100%] D:\Users\Mark\Documents\test 4\PipingTest>

[100%] D:\Users\Mark\Documents\test 4\PipingTest>ver /r

TCC  28.02.18 x64   Windows 10 [Version 10.0.19045.2251]
TCC Build 18   Windows 10 Build 19045
Registered to MARK6-WIN10

[100%] D:\Users\Mark\Documents\test 4\PipingTest>

Anytime I try to take @CON: as the text for SENDMAIL, it wants me to type from the keyboard at that point, rather than taking the text that's being piped to it.

Mark E.
 
I wouldn't expect piping to sendmail to work.

This sort of thing works. Maybe you could make an alias out of it.

Code:
command > clip: & sendmail recipient subject @clip:
 
The help contains this:
3. The message may either be entered on the command line, or it may be placed in a text file. To tell SENDMAIL to send the contents of a file as the message text, use @ sign, followed by the filename. You can use the same approach to send the text content of the clipboard (@CLIP:) or the console (@CON:):



sendmail [email protected] Party @c:\messages\invitation.txt

sendmail [email protected] Party @clip:

type myfile.txt | sendmail [email protected] Party @con:
 
Does it, perhaps, contain the first letter of the text from the file?
I wondered that, thinking that SENDMAIL would execute after it received the first newline, but apparently not so. In my test below I sent a 60K file:

Code:
d:\mercury\queue> head /n 3 v:\w32tm.log
2019-06-25 Tue 02:50:19 ntp0.cornell.edu  Correction: +0.046 s  RTT:  25 ms
2019-06-25 Tue 03:18:27 ntp0.cornell.edu  Correction: +0.018 s  RTT:  33 ms
2019-06-25 Tue 16:55:30 ntp0.cornell.edu  Correction: +0.067 s  RTT:  20 ms

I issued

Code:
type v:\w32tm.log | sendmail [email protected] test @con:

and the message the server was prepared to deliver looked like this.

Code:
Received: from spooler by vefatica.net (Mercury/32 v4.80.149); 5 Dec 2022 16:40:38 -0500
Received: from jj (127.0.0.1) by JJ (Mercury/32 v4.80.145) with ESMTP ID MG000001;
   5 Dec 2022 16:40:31 -0500
To: [email protected]
From: [email protected]
Subject: test
Date: Mon, 5 Dec 2022 21:40:31 GMT
Message-Id: <[email protected]>
 
As @evensenm pointed out, the pipe is completely ignored. @con: expects you to type something and finish it with Ctrl+Z Enter.
 
Last edited:

Similar threads

Back
Top