I use this to check my gmail from the command line (they don't include gmail in the examples). Ugly but fun:
alias gm1='curl -u USERNAME:PASSWORD --silent "https://mail.google.com/mail/feed/atom" |
tr -d '\''\n'\'' |
awk -F '\''<entry>'\'' '\''{for (i=2; i<=NF; i++) {print $i}}'\'' |
sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p" |
sed '\''s/</>/g'\'' '
EDIT and send mail by setting the headers (including MAIL FROM:<USERNAME@gmail.com>) and body (using uuencode for attachments) in email, and then: echo "$email" | netcat ISPs_MAILSERVER 25