Edited:
Try simply
curl -SIo /dev/stdout example.com 2>/dev/null | mail -s "Test" [email protected]
Well, if it's a mail problem. Your description seem strange, which version of mail are you using?
or maybe asking for sendmail directly:
/usr/sbin/sendmail [email protected] < <(
echo $'From: [email protected]\nTo: [email protected]\nDate: '$(
env LANG=C date +%c)$'\nSubject: Test'
echo
curl -SIo /dev/stdout 2>/dev/null example.com)
You could even build some more sophisticated job:
MyVar="$(curl -SIo /dev/stdout 2>/dev/null example.com)"
/usr/sbin/sendmail [email protected] < <(
echo $'From: [email protected]\nTo: [email protected]\nDate: '$(
env LANG=C date +%c)$'\nSubject: Server resp: '${MyVar%%$'\r'*}
echo
echo "$MyVar")
So you could have the initial server response in the subject.
This is not a reserved sendmail feature!
I was using this kind of method from many years, first under sendmail, but this work with the same syntax (ie calling ../sbin/sendmail binary or wrapper directly, with a formated mail as header + empty line + body ) with all MTA I've ever used upto now (sendmail, qmail, postfix, exim).
Nota Some (old) MTA complain about presence (or not) of a CR or \r at end of lines, maybe some sed 's/$/\r/' could help.
mailare you using, try this in a freed environnement.