Send batch emails from terminal with attachments
curl
You can bypass setting up mail and use curl to talk directly to your SMTP server. See using curl to send email for more details:
curl --ssl-reqd \
  --url 'smtps://smtp.gmail.com:465' \
  --user 'username@gmail.com:password' \
  --mail-from 'username@gmail.com' \
  --mail-rcpt 'john@example.com' \
  --upload-file mail.txt

mail.txt file contents:
From: &quot;User Name&quot; &lt;username@gmail.com&gt;
To: &quot;John Smith&quot; &lt;john@example.com&gt;
Subject: This is a test

Hi John,
I’m sending this mail with curl thru my gmail account.
Bye!

To attach a file, see the link recommended by lhs, curl : send html email with embedded image and attachment.