1

How can I add attachment to mailx mail?

mail -s "my subject" -a /home/foo/dummy.log me@me.com

when using the above I get email and the body test is /home/git/dummy.loginstead of the actual file

user829174
  • 6,132
  • 24
  • 75
  • 125

2 Answers2

0

According to this use you should use:

echo "MESSAGE BODY" | mailx -s "SUBJECT" -a "FILEPATH" -a "ANOTHERFILE" USER@DOM.TLD

ursusd8
  • 227
  • 2
  • 7
0

Take care if you are under HP-UX system you should use this :

( cat message_content_file; ux2dos attachment_file.txt | uuencode attachment_file.txt attachment_file.txt ) | mailx -m -s "subject" -r mail@sender mail@recipient

The attachment file can differ from .txt

Hope it can help !

peltho
  • 116
  • 6