Send batch emails from terminal with attachments I would like to write a bash script that does the following:

Read from an excel file a column of email addresses
For each email address (say person1@wherever) attach an associated file (say person1.xlsx) and send email with standard body.

In parts I have most of what I need except the mail bit doesn't seem to work for me. I tried the following:
echo &quot;hello world&quot; | mail -s &quot;test email&quot; geoff@here.com

Yet the email doesn't arrive. In the terminal under mail I see:
N  1 MAILER-DAEMON@Name  Sat Jun 27 12:02  72/2630  &quot;Undelivered Mail Returned to Sender&quot;

I have Mac OSX Catalina.
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.