If you need to send an email from the command line or a script that contains both a mail body and an attachment you can use the below command:
mailx -s "Subject of this email " -r "sent-from@somewhere.com" -a file_name.txt sent-to@somewhere.com << EOF This will be the first line of the body of the email. 2nd line. 3rd line. EOF