I am currently using the following command to send emails from my Ubuntu server, which I adapted from this question's answer: https://unix.stackexchange.com/a/90881/166614printf subject: the subject\n\nMessage body| (cat - && uuencode $attach $(basename $attach)) | ssmtp <email>My only problem so far is that the command above creates two attachments consisting of the file indicated by the $attach variable and a text file containing what's supposed to be the message body with a seemingly random number for a name. If I remove the (cat - && uuencode $attach $(basename $attach)) command, the email has a body as it should but (obviously) no attachment. Conversely, if I remove the body, the text file attchment is not present.Does anyone know how I can send an email through SSMTP with both a body and attachment?
SSMTP: Can't send email with both a body and attachment
email;ssmtp
I ultimately decided to use mpack to accomplish this task. While this doesn't answer the exact question I posed, I think mpack provides a simple way of sending emails without installing email clients with functionality that you might not need.That said, if anyone can answer the exact question, they are welcome to post it.This is the command I'm now using to send an email from the command line with a body and attachment:attachment=/location/of/attachmentprintf Body text here. | mpack -a -s Subject here -d /dev/stdin -m 0 -c $(file -b --mime-type $attachment) $attachment XavierJDHdeRauville@yahoo.com