13

This exact question was posted by user 'anvd' on 29th July but then removed - I found it on Google Cached version...!

I'm guessing the fix was something obvious, but would be great if it wasn't removed.

I am trying this command to send an email with an attachment.

echo 'These are contents of my daily backup' | mail -s 'Daily backup' -a /tmp/filename.gz mymail@hotmail.com

The error: mail: Invalid header: /tmp/filename.gz

The email gets sent, but the attachment is not attached.

This used to work, and still dos on other systems, but not sure what has changed on one of my machines...

user246977
  • 131
  • 1
  • 1
  • 4

1 Answers1

24

I just had this problem. It turns out that -a is the flag for appending headers, whereas -A is the flag for attaching files.

Kyle_S-C
  • 1,107
  • 1
  • 14
  • 31
  • 3
    Apparently the -a and -A switches vary by distro. On some (Ubuntu is what I'm currently looking at), -A is to execute an account command, and -a is to attach a file. – siliconrockstar Apr 18 '17 at 02:35
  • 3
    I think the only appropriate response to this is "ugh". Thanks for the extra datapoint. – Kyle_S-C Apr 20 '17 at 13:36