Send email from script through the TrueNAS system?

My TrueNAS is set to use Gmail OAuth to send system emails.

I have a script that will send email if the script encounters an error. I set it up to use normal SMTP of Gmail with user:password authorization. I did this by putting the info in /etc/mail.rc and the script uses the mail command.

This actually worked for a while as I was testing and refining the email. Then Gmail decided it didn’t like it. Using curl to send it I can get verbose feedback, and I get:

. . .
< 535-5.7.8 Username and Password not accepted. For more information, go to
< 535 5.7.8 d9443c01a7336-1f46c3f640fsm26491555ad.302 - gsmtp
* Closing connection 0
* TLSv1.3 (OUT), TLS alert, close notify (256):
curl: (67) Login denied
* Closing connection -1
curl: (3) URL using bad/illegal format or missing URL
Tabernacle:~$ test.zsh

The URL and user/pass are exactly the same that worked before. The link they give just goes to generic help page; no specific info about the rejection. So my question is, is there any way I can go through the system to send it via Gmail OAuth?

I’m guessing the lack of reply means nobody knows a way to do it. @kris do you know?

FWIW, I’ve in the past setup a truenas system to login to the ISPs provided email system to send emails.

Ie the isp providing access to the truenas system may provide a mailbox as part of the service. These days because of spammers secure smtp with username/passwords is often required

Best thing is to avoid Gmail. After all, google don’t really want you to use it either.

These days I run my own mailserver with backup Mx.

Thanks, @stux. I finally found my problem and got the curl email to work. I posted detailed info and a test script on Stack Exchange, but only got semi-negative feedback from one person. Then I tried showing the script to ChatGPT, which instantly nailed the problem. I’m embarrassed to say it was a stray space after the \ end-of-line character in the curl command. I had no idea that would cause havoc.

I am stunned to find that ChatGPT answers all my scripting questions accurately and very clearly. It always understands what I’m asking and has the answer. It’s like having an expert working on the project with you.