Neil ParkerMon Apr 10 22:35:52 PDT 2006
Bob Miller wrote, >( > echo EHLO example.com > echo RCPT To: recipient at example.com > echo MAIL From: sender at example.com > echo DATA > sed 's/^.$//' < a_file > echo '.' >) | nc -q10 localhost smtp The sed command should probably be sed 's/^\.$//' < a_file instead. Without the backslash, it matches, and blanks out, any line consisting of exactly one arbitrary character. What you want is to match any line consisting of exactly one period. Though actually, if memory serves, correct dot quoting goes more like this: sed 's/^\.$/../' < a_file or something like that. But since the sender is running as root, the su method, as described by Patrick, is probably the most transparent way to do it. su sender -c 'mail -s "subject" recipient at there < message_file' Of course this only works if "sendinguser" is a real user on your machine. If you want the mail to appear to be from a nonexistant user (a mail alias, for example), lower-level access is necessary, such as Bob's SMTP example quoted above, or you can call your mail agent directly...if you're using sendmail, it looks something like this: ( echo "From: sender at here" echo "To: recipient at there" echo "Subject: Foo bar baz" echo cat message_file ) | sendmail -i -fsender recipient at there - Neil Parker