How to read mail via command on Mac?
This is to me to know AppleScript with shell script.

My purpose is to use this to check the hard drive size. 

I answer here.

#!/bin/bash
var=$(df -h / | tail -n 1 | awk '{print $4}' | sed 's|Gi||g'); 
checker=;

if [ ${var} -lt 40 ]; then 
  checker=0;
  echo "The space is less than 40 Gb."
else 
  checker=1;
  echo "The space is more than 40 Gb."
fi

if [ ${checker}=1 ]; then
  osascript &lt;&lt;'EOD'
tell application "Mail"
    set theFrom to “someone@gmail.com"
    set recipientName to ""
    set recipientAddress to “nobody@gmail.com"
    set theSubject to "The rest of hard drive space is less 40Gb"
    set theMessage to make new outgoing message with properties {sender:theFrom, subject:theSubject, visible:false}
    tell theMessage
        make new to recipient with properties {name:recipientName, address:recipientAddress}
        send
    end tell
end tell
EOD
fi