Automating email with attachments from NocoDB to Mailgun

Hey everyone,

I’m stuck on a project and could use some help. I’m trying to set up an automated system that sends emails through Mailgun whenever there’s a new entry or update in my NocoDB table. The tricky part is that one of the table columns contains attachments, and I need these to be included in the emails.

What I’m struggling with is:

  1. How to handle the attachment column in NocoDB
  2. Getting the file URLs from that column
  3. Downloading the files from those URLs
  4. Adding them as attachments in the Mailgun email

Has anyone done something similar before? Any tips or code snippets would be super helpful. I’ve been banging my head against this for a while now and could really use some guidance.

Thanks in advance for any help!

hey there, i’ve used nocodb with mailgun before.

use the attachment column for file URLs, fetch them via the API, download with axios, and attach in mailgun.

hope that helps!

I’ve implemented a similar system using NocoDB and Mailgun. Here’s what worked for me:

For the attachment handling in NocoDB, use the ‘Attachment’ column type. It stores file URLs which you can retrieve later.

To automate the process, set up a webhook in NocoDB that triggers on new or updated entries. In your webhook handler, fetch the entry details including the attachment URL.

For downloading attachments, I found the ‘got’ library in Node.js to be reliable. It handles streams well, which is crucial for larger files.

When sending via Mailgun, use their ‘messages’ API endpoint. You can pass the downloaded file as a buffer in the ‘attachment’ field of your API request.

A word of caution: implement error handling for failed downloads or oversized attachments, and consider rate limiting if you’re dealing with a high volume of emails.

This approach has been working smoothly for me. Hope it helps!

I’ve actually tackled a similar challenge recently, and I can share some insights that might help you out.

For handling attachments in NocoDB, make sure you’re using the ‘Attachment’ column type. This stores file URLs that you can later access.

To get the file URLs, you’ll need to use NocoDB’s API. You can set up a webhook or use their REST API to fetch new or updated entries. The attachment column will contain the file URLs.

For downloading files, I’d recommend using a library like ‘axios’ or ‘node-fetch’ in Node.js. These make it easy to download files from URLs.

When it comes to Mailgun, their API supports adding attachments directly. You can use the ‘attachment’ parameter in your API call, passing the file data you’ve downloaded.

One gotcha to watch out for: make sure you’re handling large attachments properly. You might need to implement some kind of file size limit or chunking mechanism to avoid timeouts or memory issues.

Hope this helps point you in the right direction. Let me know if you need any more specific advice!