Sending an email in Python is a breeze

Here we'll show you how to use our Python SDK to send an email with the Gmail API.

Get Set Up

1 Log in to Temboo. If you don't already have an account, you can register for free.

2Make sure you've downloaded the Temboo Python SDK and that you've added it to your development environment as described in our Python getting started tutorial.

3You'll also need a Gmail account, which you can create here. To authenticate with Google, you'll want to enable 2-Step Verification and generate an App Password for Temboo.

4Sign in to your Google Account settings page by clicking on your name or picture in the upper right corner of the screen and then clicking Account.

5Scroll down to the "Signing in" box.

6Click 2-Step Verification. This will bring you to the 2-Step Verification settings page.

7You will then see a step-by-step guide which will guide you through the setup process.

8After you've enabled 2-Step Verification, you'll be prompted to create an App Password.

9In the Select app dropdown menu, choose "Other", and give this app a name (e.g., TembooApp).

10Click "Generate". You'll be given a 16-digit passcode that can be used to access your Google Account from Temboo.

Note: If you wish to authenticate with OAuth credentials, you should use the Google > Gmailv2 Choreos.

11 Go to the Google > Gmail > SendEmail Choreo in our Library. Select Python from the drop down menu at the top of the page.

12Fill in your Gmail username (email address) and App-specific password, then hit the Save Profile button to save a Profile for your Gmail account. Now you can reuse your Gmail authentication details on any of our Gmail Choreos and it will also make your Python code simpler and more secure.

Test the Choreo

13Now let's test the Google > Gmail > SendEmail Choreo directly from our website. Insert your new Profile and fill in the rest of the required inputs.

14 Click Generate Code and you'll see the value "true" for the Success output in the Output section. Assuming you emailed yourself, you can go to your inbox and see the email appear!

Create Your Python Script

15To send an email from your Python code, copy the generated code from your browser directly into a new .py file and try running it there. Your code should look something like the script below.

from temboo.Library.Google.Gmail import SendEmail
from temboo.core.session import TembooSession

# Create a session with your Temboo account details
session = TembooSession('ACCOUNT_NAME', 'APP_NAME', 'APP_KEY')

# Instantiate the Choreo
sendEmailChoreo = SendEmail(session)

# Get an InputSet object for the Choreo
sendEmailInputs = sendEmailChoreo.new_input_set()

# Set Profile to use for execution

# Set the Choreo inputs
sendEmailInputs.set_MessageBody("Test from Temboo")
sendEmailInputs.set_Subject("Hello world!")

# Execute the Choreo
sendEmailResults = sendEmailChoreo.execute_with_results(sendEmailInputs)

# Print the Choreo outputs
print("Success: " + sendEmailResults.get_Success())

16Run the code and check your inbox - your email should be waiting.

What next?

We're all finished! Now your Python application is sending email via your Gmail account. Check out what else you can do with our Python SDK by exploring the 2000+ Choreos in our Library.

Once you've got your code up and running, you're ready to move on and do more. From monitoring your running applications, to moving your generated Temboo code to your preferred development environment and sharing it with colleagues, collaborators and friends - we've got you covered.

Get Live Updates About Your Application

Integrate Temboo with Slack to get up-to-the-second notifications and alerts about your deployed Temboo code.

Commit Code to GitHub

Commit Temboo-generated code directly to GitHub and share with the world. Learn more.

Need help?

We're always happy to help. Just email us at, and we'll answer your questions.