I have this bash script that prepares and sends an email using SSMTP. The line that sends the message looks like this:

/usr/local/sbin/ssmtp -vvvv $recipients < $mail_file

$recipients: the recipient list $mail_file: the mail file

How would I attach a "/var/logs/foo.log to this mail? NB: An SSMTP-only solution is needed.

marked as duplicate by thrig, Rui F Ribeiro, roaima, Christopher, jimmij Feb 11 at 1:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If you can't change the script, replace /usr/local/sbin/ssmtp with a link to a proper MIME-aware mailer. – roaima Feb 10 at 15:42
  • I love the simplicity of SSMTP and I guess I have found an answer. Thank you. – SCilek Feb 10 at 15:47

Well... It turned out that this works just fine:

cat $mail_file | (cat - && uuencode /var/log/foo.log foo.log) | /usr/local/sbin/ssmtp -vvvv $recipients
  • 1
    Uuencode is so obsolete it's unimaginable. Use MIME and have it work properly. – roaima Feb 10 at 15:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.