Drop It Like It’s Hot: Sending Email Attachments Straight to Google Drive using Postmark

This is a submission for the Postmark Challenge: Inbox Innovators.

What I Built

Teachers, freelancers, and inbox zero purists rejoice: I built EmailDrop, a one-click AWS deployment that turns incoming emails into automatic Google Drive uploads. With Postmark’s new inbound webhooks, AWS Lambda, and a little OAuth wizardry, attachments fly straight from your inbox to your Google Drive. In this post, I’ll walk through how I built it using Postmark, CloudFormation, Google Drive, and serverless tools, and how you can deploy it with zero manual code.

Why use EmailDrop?

Circular diagram showing emails flowing from the user's email inbox to a Postmark webhook to AWS Lambda which uploads the attached files to Google Drive

  • Deploys with a single click, no coding required (see the demo below and deploy in minutes!)
  • Have your students submit their homework direct to your Google Drive, and without having to give out your real email address
  • Process documents from coworkers, employees, or customers without having to manually download attachments and upload them for editing and storage
  • Set up a photo folder for special events like weddings, birthdays, and more!

Demo

EmailDrop is a CloudFormation stack with some Python code that will simplify your email inbox. First, however, we need to gather some information from Google. Then, we’ll click a Launch Stack button that will deploy all of the infrastructure- no coding required. Then we’ll configure Postmark and wrap up. Let’s go!

Creating a Google Cloud project

Go to Google Cloud Console

Selecting API & Services

Create a Project

  • Click the project dropdown → New Project
  • Name it (e.g., PostmarkUploader)
  • Click Create

Enabling the Google Drive API

Enable the Google Drive API

  • Go to APIs & ServicesLibrary
  • Search for Google Drive API
  • Click Enable

Configuring the OAuth screen

Configure the OAuth Consent Screen

  • Go to APIs & ServicesOAuth consent screen
  • Choose External
  • Fill in:
    • App name
    • Support email
    • Developer contact email (these can all be your personal email)

Making yourself a test user

  • Add yourself as a test user using the Audience page on the sidebar
  • Click Save and Continue

Creating OAuth 2.0 credentials

Create OAuth 2.0 Credentials

  • Go to APIs & ServicesCredentials
  • Click Create CredentialsOAuth client ID
  • Choose Web application
  • Skip the redirect URI for now — you’ll add it after deploying the stack
  • Click Create
  • Save the Client ID and Client Secret

Launch Stack

Deploy the CloudFormation Stack

  • Click the “Launch Stack” button above!
  • Name the stack anything you wish.
  • Fill in the parameters:
    • GoogleClientId: (from step 5)
    • GoogleClientSecret: (from step 5)
    • GoogleDriveFolder: (optional) Name of the folder to store attachments
    • LambdaTimeout: (optional) Default is 60 seconds. Increase for large attachments (up to 900s)

Allowing AWS to create new IAM resources for you
– Agree to let AWS create new IAM resources and click `Create Stack’. EmailDrop will take several minutes to deploy.

Copying the redirect URI and going through the Auth Flow

Add the Redirect URI

  • Once the stack is deployed, go to the Outputs tab in CloudFormation
  • Copy the OAuthURL output

Adding the redirect URI on Google Cloud

  • Return to Google Cloud Console → Clients
  • Click on your OAuth 2.0 client
  • Edit the Authorized redirect URIs
  • Paste in the URL you copied from the stack output
  • Save changes

Authorizing Google Drive access
Complete the OAuth Flow

  • In the stack outputs, find the OAuthURL
  • Open it in your browser
  • Click the link to begin the authentication flow, as shown above.

Google Unverified App

  • You will get a warning that Google has not verified this application. Click ‘Continue’
  • Approve access to Google Drive
  • The Lambda will exchange the code for tokens and store them

Successful authentication

  • You can now close this page, authentication is finished!

Create a Postmark Account

Setting up Postmark

Set Up Inbound Email Processing
– In your Postmark dashboard, navigate to ServersYour Server NameDefault Inbound Stream
– Navigate to Setup Instructions
– Note your unique inbound email address

Adding your webhook URL and ensuring Lambda gets the JSON payload from Postmark

Configure Webhook URL
– From the Settings page, find the Webhook URL field
– In the CloudFormation stack outputs, find the PostmarkWebhookURL value
– Copy this URL and paste it into the Postmark Webhook URL field
– Check the box that will send the JSON payload to your Lambda function. EmailDrop parses this JSON to extract the attachments.
– Save your changes

Email attachments in your Google Drive folder

Test the Integration
– Send an email with attachments to your Postmark inbound email address
– The attachments should be automatically uploaded to your Google Drive folder
– Check the Lambda logs in CloudWatch if you encounter any issues

Code Repository

GitHub logo

kevinl95
/
EmailDrop

Automatically upload attachments to emails sent to your Postmark inbound email address to Google Drive

EmailDrop: Postmark to Google Drive Attachment Uploader

Lint CloudFormation Template

This application automatically uploads email attachments from Postmark to Google Drive. When emails are sent to your Postmark inbound email address, any attachments are automatically saved to your specified Google Drive folder. The system uses AWS Lambda, API Gateway, and Secrets Manager to handle the OAuth flow and file uploads.

Architecture

  • Postmark: Receives emails and sends attachment data via webhooks
  • API Gateway: Provides endpoints for OAuth callback and Postmark webhook
  • Lambda Functions: Handle OAuth flow and attachment uploads
  • Secrets Manager: Securely stores OAuth refresh tokens
  • Google Drive API: Destination for email attachments

Setup Instructions

1. Google Drive API Setup

1.1 Go to Google Cloud Console

1.2 Create a Project

  • Click the project dropdown → New Project
  • Name it (e.g., PostmarkUploader)
  • Click Create

1.3 Enable the Google Drive API

  • Go to APIs & ServicesLibrary
  • Search…

How I Built It

This project started as a simple idea: I wanted to extract attachments from emails and send them to Google Drive automatically. Drive does not offer this feature natively. Postmark’s Inbound Webhooks made that possible with a clean, reliable way to receive structured email data, including base64-encoded attachments, via a JSON payload.

Architecture diagram of the CloudFormation stack

I used AWS CloudFormation to make the whole serverless solution deployable in one click. The stack provisions:

  • An OAuth token exchange Lambda: Handles the OAuth 2.0 flow with Google, exchanging an authorization code for tokens. It outputs a working Google OAuth link via CloudFormation so users can grant access easily.
  • An upload Lambda: Triggered by Postmark’s inbound webhook. It decodes the attachments and uploads them to the authenticated user’s Google Drive using the Drive API.
  • An API Gateway: Routes the Google OAuth redirect to the token exchange Lambda function.

Here’s how it works:

Data flow diagram showing how attachments trigger a Postmark webhook which triggers the Lambda function that uploads the files to Google Drive

To keep things simple, I made sure the user experience didn’t require running any local code or setting up servers. Once the stack is deployed, the user just needs to:

  • Set up a Google Cloud project.
  • Deploy the CloudFormation template with their OAuth credentials.
  • Complete the auth flow by visiting a link output by the stack.
  • Configure Postmark to send inbound emails as a JSON payload to the webhook.

All credentials and logic are encapsulated in AWS Lambda functions using Python 3 and the standard library, keeping dependencies minimal. Tokens are stored in Amazon’s Key Management Service, which lets EmailDrop securely manage all information needed to authenticate with the Google Drive API.

My experience with Postmark was great, the inbound webhook fature is fast and extremely easy to consume. Having the full email (plus parsed fields and attachments) delivered via HTTP was a huge time-saver compared to working directly with IMAP or polling APIs. Being able to extract content from emails in a structured way will make a number of projects and tools much easier to build, and I look forward to using Postmark’s inbound features again!

Leave a Reply