(Note: I have seen this question, but it does not work for me)
I am attempting to send an email with an attachment using Bash on Debian Stretch, using the mailx
package (not mutt). My implementation does not support the -A
parameter (it's an invalid option), and the -a
parameter is for adding headers.
I have tried many variations of the following, but they fail for me:
mail -s "Test" -a /home/user/filename.xlsx user@example.com < /root/emailbody.txt
The end effect is a plain-text email with the filename as the first line, the header content, then the data inside /root/emailbody.txt
:
/home/user/filename.xlsx
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Hi there
I do not have uuencode
, and many threads are reporting that's the "old" way of sending attachments. I cannot install mutt
on this server. What are my options?
Update with uuencode - I tried running it as the following, but only got "Hi there" as the email result, no attachment:
uuencode /home/user/filename.xlsx test.tlsx | mail -s "Test" user@example.com < /root/emailbody.txt
/root/emailbody.txt
file in the body, and no attachment. I'll update the question. – Canadian Luke Jun 14 '19 at 18:00uuencode
is the old way. That's the main reason I wanted to avoid it. – Canadian Luke Jun 14 '19 at 19:06