Home > Enterprise >  How to send email via terminal
How to send email via terminal

Time:03-10

I have a script that I wrote that scrapes relevant information from an Excel file, creates a text file and then sends that to the recipient. A sort of homemade mail merge that I executed via terminal. The key command was something of the form:

curl --ssl-reqd 
     --url 'smtps://smtp.gmail.com:465' 
     --user '[email protected]:mysecretpassword' 
     --mail-from '[email protected]' 
     --mail-rcpt '[email protected]' 
     --upload-file 'filename.txt'

I got all this by working through questions and answers from here. It worked well but recently Gmail won't allow me to do this anymore. This is due to account security, two-factor authentification. My question is, how can I continue sending emails through the terminal? How do I modify the command above?

CodePudding user response:

Ever since google deprecated Less secure apps, you'll have to use an "App Password" https://support.google.com/accounts/answer/185833?hl=en

P.S. This requires 2-factor authentication enabled for your google account.

  • Related