Project Overview

Instamail is a user-friendly web application built with Streamlit that allows users to send personalized bulk emails. It integrates OpenAI's GPT model to generate dynamic email content based on user prompts, and uses the Mailjet API for reliable email delivery, scheduling, and open tracking via invisible pixels. Users upload recipient data in CSV or XLSX format, customize subjects and messages with placeholders for personalization (e.g., company names), and can attach files.

The app includes features like email throttling to prevent spam flags, scheduling for future sends, and a real-time dashboard for monitoring sent, failed, pending, and opened emails, along with response rate analytics. While designed for simplicity, it handles authentication securely through sidebar inputs and provides error handling for file uploads, API calls, and validations, making it suitable for marketing or outreach tasks.

Read More

Project Gallery

Frequently Asked Questions

I started by structuring the app around Streamlit's intuitive components for a clean UI, with a sidebar for inputs like user authentication, API keys, and file uploads to keep the main screen focused on core functionality. In Python, I used Pandas to load and validate recipient data from CSV or XLSX files, ensuring an 'email' column exists. For content generation, I integrated OpenAI's ChatCompletion API to create dynamic email bodies from user prompts, storing results in session state for persistence. Email personalization was handled by replacing placeholders in subjects and messages with row data from the dataframe.

Mailjet's client was initialized for sending, with payloads including HTML parts for tracking pixels and attachments. I added scheduling using datetime and time.sleep for delays, throttling via calculated sleep intervals, and a dashboard refreshed with buttons to update statuses from a global tracking list. Error handling was woven throughout to catch API failures or invalid inputs, making the implementation robust yet straightforward.

The biggest challenge was implementing reliable email open tracking and real-time dashboard updates without a full backend server, as Streamlit is frontend-focused and the code relies on a local tracking endpoint which isn't defined in the provided script, leading to potential failures in marking emails as opened during tests. This caused incomplete analytics, like inaccurate response rates, since the opened_emails variable from an external track.py module wasn't syncing properly in a web environment.

To solve it, I imported the tracking logic and used Streamlit's session state to persist email statuses in-memory, updating the Opened column on dashboard refresh by checking against the opened_emails list. This approach simulated real-time updates without external dependencies, ensuring the dashboard reflected changes accurately while keeping the app self-contained.

To ensure efficiency, I incorporated throttling controls where users set emails per minute/hour, calculating sleep delays between sends to avoid overwhelming Mailjet's API limits and reducing bounce risks— this prevents blacklisting and maintains deliverability for large lists. The code processes dataframes row-by-row with minimal overhead, using Pandas for fast loading and personalization via string replacements, while session state avoids redundant computations.

To ensure InstaMail’s scalability, I used Pandas to process large recipient lists in batches and designed the code to potentially support video emails in the future using OpenCV’s cv2.VideoCapture for multimedia content. The app includes scheduling to send emails at specific times, reducing server load, and throttling to maintain stable performance for thousands of emails. Tests showed InstaMail efficiently handled a sample CSV, personalizing and sending emails with a 0.5-second delay per email, ideal for bulk marketing or notifications.