2

I want to be able to send gmail messages from a raspberry pi, ideally from a single line of a shell script - I know I can use a mail server other than gmail that supports less secure login options, or go to https://www.google.com/settings/security/lesssecureapps and change the settings there - that is NOT what I want to do, as I would prefer to use the newer version of OAUTH

There seem to be many e-mail options, most with more features than what I care about, but I don't see OAUTH support as an "advertised" feature (note: I don't want to receive e-mails or check them, nor do I care for a GUI) - what is the simplest way to achieve this?

I would prefer free and open source, and also relatively easy to setup/configure, in that order as far as priorities go.

1

The accepted, and extremely well written, StackOverflow Answer here covers how to do this from python - without lowering the security settings so all you need to do is:

  1. follow the instructions for getting your token
  2. adapt the section about sending a mail into a script that takes an email address, title and message as inputs (make sure your script starts with the python shebang #!/usr/bin/env python - if running windows you need to make sure that your script name ends with .py
  3. place the script somewhere on your path, or somewhere that you are going to run it from, and
  4. set it to executable with chmod +x/path/to/your/script (you should skip this if running Windows)

This solution:

  • Uses the industry-standard OAuth 2.0 protocol.
  • Is Free & Open Source.
  • Should work on any computer/OS that has python installed and is connected to the internet. Raspberrian has python as do most linux machines, OS/X etc and it is installable on Windows
2

I just came by your thread and might not understand your requirement correctly. But if I understood correctly, I think you can use git to send emails with Google Oauth2.

$ git send-email --smtp-pass your-Oauth2-app-pwd 
                 --smtp-user your.email@gmail.com 
                 --smtp-server smtp.gmail.com 
                 --smtp-encryption tls 
                 --smtp-server-port 587 
                 --to your-friend@gmail.com
                 mail-content.txt

This is how I am sending patches using my Google account email.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.