Use sendmail without standard input

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)?

Silicomancer

Posted 2015-10-11T08:56:17.950

Reputation: 175

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 – 2015-10-11T11:22:13.377

Answers

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.

user1686

Posted 2015-10-11T08:56:17.950

Reputation: 283 655

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 – 2015-10-11T10:58:42.767