Skip to content
Tildev0.6.1

Send mail and chat

This page shows how to send one email or one chat message from the command line, so a script or a cron job can do it. The body is always the standard input.

Terminal window
tcli send email --to ann@example.org --subject "Notes" < notes.txt

--to and --subject are required. The message goes out through the mail transport of the account, and the server has 60 seconds to take it. Nothing is kept in a Sent folder.

More recipients, copies and an attachment:

Terminal window
echo "done" | tcli send email --to ann@example.org --to "Lee, Bob <bob@example.org>" --cc team@example.org --subject "Build" --attach build.log
  • A recipient is an address or Name <address>. --to, --cc and --bcc can be given more than once, and a value can be a list separated by commas.
  • --attach names a file and can be given more than once.
  • --account is the id of the mail account. Without it the only mail account is used; with more than one account it is an error.
Terminal window
tcli send email --to ann@example.org --subject "Plan" --sign --encrypt < plan.txt

--sign signs the message with OpenPGP and --encrypt encrypts it to the To and Cc recipients and to you, with a separate copy for each --bcc recipient. Both need [pgp] on: see OpenPGP.

The body is read from the standard input as UTF-8, whatever the locale says. If nothing is piped in and the input is a terminal, the command stops and says so, because it would otherwise wait for a text nobody is typing. A line break in the subject becomes a space.

Terminal window
echo "build is green" | tcli send chat --to "#tilde" --join
tcli send chat --to bob --account irc < message.txt

--to is required: a nick or a channel on IRC, a JID or a room on XMPP. --join joins the channel or the room before writing; a room on XMPP and a channel that does not take messages from outside need it. --account is the id of the chat account, with the same rule as for mail.

The text is the standard input without the final line break. On IRC every line goes out as a message of its own, and a line that starts with /me is an action. A send takes 50 lines at most.

For both commands, exit code 0 means that the message was handed to the server (email) or written to the connection (chat). A chat server answers a nick that does not exist, or a channel that is closed, after the command has left, so the exit code does not show it. An address or a target that is not valid, an account that does not exist or is not chosen, and nothing piped in give exit code 2. A refusal of the server gives exit code 1 and the reason.

tcli send chat is a second client of the account. It does not join the channels of the account and it does not reconnect. On IRC it needs the nick of the account, so it cannot run while Tilde is connected with that account. On XMPP it takes a resource of its own, and the server may hand it the messages kept for an account that was offline, which nobody reads: do not run it while Tilde is closed if you need those messages.

The accounts are on Chat accounts and Mail accounts. Every option is in the reference of tcli.