1

I would like to use sendmail to send an e-mail from my backup software on Kubuntu Linux. However the software does not allow entering a full command line (only command name and arguments pattern separately). This is why I can not pass the mail body to sendmail using standard input.

Is there a way to call sendmail without standard input usage? E.g. passing the message body by command line parameter (or even passing no body at all)?

  • You can probably get stdin to "work" this way: by spawning a shell with the redirections inside the argument:sh -c 'sendmail -oi -t < file.eml' – glenn jackman Oct 11 '15 at 11:22
1

Sure, write a shellscript that does so.

#!/bin/sh
sendmail -i "silicomancer@example.com" <<EOF
Date: ...
From: ...
To: ...
Subject: ...
Content-Type: text/plain; charset=utf-8

Yo, stuff happened ($*).
EOF

Though it might be better to use mail (aka Mail or mailx or s-nail) than hand-craft all the headers.

  • The script is an interesting idea. However using an alternate mail program actually seems the better solution. 'sendemail' works like a charm for me. – Silicomancer Oct 11 '15 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.