Sending Confirmation Emails with Resend
Author: Amit Jotwani, Sr. Developer Advocate II, DigitalOcean
Welcome to the final day of our?12 Days of DigitalOcean?series! We’ve come a long way, building an?Email-Based Receipt Processing Service?that extracts receipt details from?Postmark?using?DigitalOcean’s GenAI Agent, securely?stores attachments in DigitalOcean Spaces, and?saves the extracted data in Google Sheets.
Today, we’ll add the final touch—sending confirmation emails back to the sender with the receipt details, attachment links, and a link to the Google Spreadsheet. This final step ties everything together, ensuring that users get immediate feedback that their receipts have been successfully processed.
?? What You’ll Learn
By the end of this tutorial, you’ll know how to:
?? What You’ll Need
If you’d like to build along, we assume that you’ve followed?Day 11: Save Receipt Data and Attachments in Google Sheets?and already have:
If you’re just interested in learning how to integrate?Resend?for sending confirmation emails, you’ll need:
Step 1: Create a Resend Account and Get the API Key
To send emails programmatically, we’ll use?Resend, a developer-friendly API for sending transactional emails. It simplifies sending emails so you don’t have to wrestle with setting up an email server, managing SMTP configurations, or worrying about spam filters.
2. Give your API key a?descriptive name, like?Receipt Processor App, and set its?permission?to?Full Access.
3. Copy the API Key:?Your API key will be shown only once—copy it and keep it safe. You’ll need it in the next step to authenticate your app with Resend.
Step 2: Update Your Environment Variables
Now that we have the Resend API key, let’s save it as an environment variable in DigitalOcean, just like we’ve been doing throughout this series.
For the Resend integration, we need to save two environment variables:
To add these variables, follow these steps:
Step 3: Install the Resend Python Library
Next, we’ll install the Resend Python library to handle the API for us. It keeps your code clean and avoids dealing with raw HTTP requests. Run this in your terminal:
Step 4: Update?requirements.txt
Instead of editing?requirements.txt?by hand, use?pip freeze?to list all installed dependencies with exact versions. Run this:
This updates?requirements.txt?with everything your app needs, including?resend.
Step 5: Write the Function to Send Emails
Now it’s time to add the logic for sending confirmation emails. Think of it like emailing a friend to let them know their package has arrived—only here, it’s for receipts.
We’ll write a?send_confirmation_email?function that takes the recipient’s email, receipt details, attachment links, and Google Spreadsheet URL. Using Resend, it will format this into an email and send it. Here’s the function:
Step 5: Deploy to DigitalOcean
To deploy the updated Flask app, follow the steps from?Day 7: Building and Deploying the Email-Based Receipt Processor. Here’s a quick summary:
2. Monitor Deployment: You can track the progress in the?Deployments?section of your app’s dashboard.
3. Verify Your Deployment: After the deployment completes, navigate to your app’s public URL and test its functionality. You can also check the?runtime logs?in the dashboard to confirm that the app started successfully.
领英推荐
4. Check Runtime Logs: If something isn’t working as expected, use the?Runtime Logs?tab in the App Platform dashboard to debug runtime issues. Look for any errors related to the Resend API or other app components.
Step 5: Test the Entire Workflow
Now that your app is fully configured and ready, it’s time to test the entire workflow. We’ll ensure that the?email body is processed, attachments are decoded and?uploaded to DigitalOcean Spaces, receipt details and attachment URLs are?saved in Google Sheets, and a?confirmation email is sent?to the sender.
Here’s how you can test step by step:
2. Check Postmark Activity JSON: In the Postmark dashboard, navigate to the?Activity?tab. Locate the email you sent and ensure that the JSON payload includes the text body and Base64-encoded attachment data. This confirms Postmark is correctly forwarding the email data to your app, as we set up in?Day 8.
3. Monitor the Logs: Check the runtime logs in your DigitalOcean App Platform dashboard to ensure the app processes the JSON payload. You should see logs showing that receipt details were extracted and attachments were uploaded to DigitalOcean Spaces. You can access the runtime logs in the?Logs?tab of the DigitalOcean App Platform dashboard. If you’re not familiar with DigitalOcean logs, we explored this during?Day 9: Automating Receipt Parsing withDigitalOcean’s GenAI Agent.
4. Verify Spaces Upload: Visit your DigitalOcean Space to confirm that the files were uploaded successfully. You should see the attachments in your bucket as configured in?Day 10: Storing Attachments in DigitalOcean Spaces. If everything went as expected, your attachment URLs will be accessible.
5. Check Google Sheets: Open your Google Sheet and confirm that a new row with receipt details and attachment URLs has been added, as we set up on?Day 11: Saving Receipt Details in Google Sheets. The row should include:
6. Verify the Confirmation Email: Finally, check the inbox of the sender’s email address to ensure the confirmation email was received. This email should contain:
Troubleshooting
If the workflow doesn’t work as expected, here are a few troubleshooting steps to follow:
?? Wrap-Up
Congratulations! You’ve successfully completed the?12 Days of DigitalOcean?series and built a fully functional?Email-Based Receipt Processing Service.
Today, you:
By adding confirmation emails, you’ve wrapped up a project that processes emails, extracts details, stores attachments, and keeps everything organized in Google Sheets. It’s user-friendly, practical, and ready to solve real-world problems.
?? The 12 Days of DigitalOcean
This marks the end of the?12 Days of DigitalOcean?series. Over the past 12 days, we’ve built two real-world applications, one step at a time. Along the way, you’ve used tools like DigitalOcean’s?Serverless Functions,?App Platform,?Spaces Object Storage,?PostgreSQL,?DigitalOcean GenAI,?Twilio,?Google Sheets API,?Postmark,?PaperTrail, and?Resend. Each piece came together to form something greater than the sum of its parts.
Here’s a quick recap of what you’ve built:
?? Days 1–6: Build a Birthday Reminder Service
This app tracks birthdays and sends SMS reminders automatically. It’s lightweight, serverless, and easy to maintain.
By Day 6, you have a fully automated service running in the cloud. It just works.
?? Days 7–12: Build an Email Receipt Processor
This app handles emailed receipts, extracts the needed details, and organizes everything in a database.
By Day 12, you’ve built a complete tool that handles receipts end-to-end.
What You’ve Learned
What’s next
This is just the beginning—what you’ve learned here can be applied to countless other projects. Here are a few ways to keep going:
If you follow along, I’d love to see what you create—feel free to share your progress or feedback with me on?Twitter.
Keep it simple. Build something useful. Happy building! ??
Looking for more Tutorials like this? Check out the DigitalOcean Community Page.