Linux: Sending Email without a Mail Client

A “minihowto”…

In Gentoo, install mail-client/mailx. In other distros, an adequate package for the Heirloom mailx client.

The command to send a mail with a preconfigured body (in body.txt file) and the attachment in an Office document (e.g. attachment.odt file) is as follows:

(echo -e "To: mailbox@domain.tld"; cat body.txt) | mail -t -a attachment.odt

where the body.txt file has the following structure:

cat body.txt
Bcc: mailbox@domain.tld
Reply-To: mailbox@domain.tld
Subject: This is an email subject

Dear Recipient,
blabla...
Advertisements
This entry was posted in Linux, Server and tagged , , , , . Bookmark the permalink.