Email Tracker is a comprehensive email tracking system designed for B2B marketing campaigns. It enables users to send bulk emails with tracking functionality, monitor email opens and replies, and analyze engagement statistics. The system uses a combination of Python services for email sending, tracking, and statistical analysis.
- Email Sending: Automated bulk email sending with personalized templates
- Email Tracking: Real-time tracking of email opens through tracking pixels
- Reply Detection: Automatic detection of email replies
- Statistics and Analytics: Detailed reporting of email campaign performance
- API Server: RESTful API for managing email tasks and viewing statistics
- Database Integration: MySQL database integration for storing contact information and tracking data
- Region/Country Targeting: Send emails to contacts based on geographic regions or specific countries
The system consists of the following components:
- Email Sender (
email_sender.py): Handles the email delivery process, connects to SMTP and IMAP servers - Tracker Server (
tracker_server.py): Records email opens using tracking pixels - Feedback Server (
feedback_server.py): Processes and records email replies - API Server (
api_server.py): Provides RESTful API for system management - SQL Tools: Utilities for database operations
add_email_id_column.py: Adds an email_id column to the email_tracking tablemysql_connection.py: Handles database connection and table creation
The system includes multiple customizable email templates:
A_template.html: Product offering with detailed vegetable listsB_template.html: Product offering with product imagesC_template.html: Cooperation opportunity with certification information
- Python 3.6+
- MySQL Server
- SMTP/IMAP mail server access
-
Clone the repository:
git clone https://github.com/yourusername/email_tracker.git cd email_tracker -
Install dependencies:
pip install -r requirements.txt
-
Configure database connection in the SQL tools files
-
Initialize the tracking table:
python sql_tools/mysql_connection.py
-
Add email_id column to the tracking table:
python sql_tools/add_email_id_column.py
-
Start the tracking server:
python tracker_server.py
-
Start the feedback server:
python feedback_server.py
-
Start the API server:
python api_server.py
Run the email sender to start interactive mode:
python email_sender.pyThis will present a menu with options to:
- Send emails immediately
- Check for email replies
- View statistics
- View email open status
- Modify send interval
The API server runs on port 8000 and offers endpoints for:
- Starting email campaigns:
POST /start - Stopping email campaigns:
POST /stop - Checking campaign status:
GET /status - Viewing statistics:
GET /stats - Triggering immediate sending:
POST /send-now
Example API request to start a campaign:
curl -X POST http://localhost:8000/start \
-H "Content-Type: application/json" \
-d '{"daily_count": 50, "target_regions": ["南美洲", "东南亚"], "send_time": "09:00", "template_name": "A_template.html"}'Configuration files are stored in the config directory:
api_config.json: API server configurationrecipients.json: Test recipients listregions.json: Region to country mappings
The system uses environment variables for sensitive information such as database credentials and email settings. To set up:
-
Create a
.envfile in the root directory based on the following template:# 数据库配置 DB_HOST=your_database_host DB_USER=your_database_user DB_PASSWORD=your_database_password DB_NAME=your_database_name # 邮件服务配置 SMTP_SERVER=your_smtp_server SMTP_PORT=465 IMAP_SERVER=your_imap_server IMAP_PORT=993 EMAIL_USERNAME=your_email_username EMAIL_PASSWORD=your_email_password SENDER_NAME=your_sender_name TRACKER_URL=http://localhost:5000 -
Ensure the
.envfile is included in your.gitignoreto prevent sensitive information from being committed to your repository.
- With the environment variable configuration, sensitive credentials are no longer stored in code.
- Consider implementing rate limiting to avoid being flagged as spam.
[Your License Here]
Email Tracker是一个全面的电子邮件追踪系统,专为B2B营销活动设计。它使用户能够发送带有追踪功能的批量电子邮件,监控邮件打开和回复情况,并分析互动统计数据。该系统结合使用多个Python服务来实现邮件发送、追踪和统计分析功能。
- 邮件发送:使用个性化模板自动批量发送邮件
- 邮件追踪:通过追踪像素实时监控邮件打开情况
- 回复检测:自动检测邮件回复
- 统计和分析:提供电子邮件活动效果的详细报告
- API服务器:用于管理邮件任务和查看统计数据的RESTful API
- 数据库集成:与MySQL数据库集成,用于存储联系人信息和追踪数据
- 区域/国家定向:根据地理区域或特定国家向目标联系人发送邮件
系统由以下组件组成:
- 邮件发送器 (
email_sender.py):处理邮件投递过程,连接SMTP和IMAP服务器 - 追踪服务器 (
tracker_server.py):使用追踪像素记录邮件打开情况 - 反馈服务器 (
feedback_server.py):处理和记录邮件回复 - API服务器 (
api_server.py):提供系统管理的RESTful API - SQL工具:用于数据库操作的实用工具
add_email_id_column.py:向email_tracking表添加email_id列mysql_connection.py:处理数据库连接和表创建
系统包含多个可自定义的电子邮件模板:
A_template.html:产品报价,含详细的蔬菜列表B_template.html:产品报价,含产品图片C_template.html:合作机会,含认证信息
- Python 3.6+
- MySQL 服务器
- SMTP/IMAP邮件服务器访问权限
-
克隆仓库:
git clone https://github.com/yourusername/email_tracker.git cd email_tracker -
安装依赖:
pip install -r requirements.txt
-
在SQL工具文件中配置数据库连接
-
初始化追踪表:
python sql_tools/mysql_connection.py
-
向追踪表添加email_id列:
python sql_tools/add_email_id_column.py
-
启动追踪服务器:
python tracker_server.py
-
启动反馈服务器:
python feedback_server.py
-
启动API服务器:
python api_server.py
运行邮件发送器以启动交互模式:
python email_sender.py这将显示一个菜单,提供以下选项:
- 立即发送邮件
- 检查邮件回复
- 显示统计信息
- 查看邮件打开情况
- 修改发送间隔
API服务器运行在8000端口,提供以下端点:
- 启动邮件活动:
POST /start - 停止邮件活动:
POST /stop - 检查活动状态:
GET /status - 查看统计数据:
GET /stats - 触发立即发送:
POST /send-now
启动活动的API请求示例:
curl -X POST http://localhost:8000/start \
-H "Content-Type: application/json" \
-d '{"daily_count": 50, "target_regions": ["南美洲", "东南亚"], "send_time": "09:00", "template_name": "A_template.html"}'配置文件存储在config目录中:
api_config.json:API服务器配置recipients.json:测试收件人列表regions.json:区域到国家的映射关系
- 本系统在代码中以明文存储SMTP/IMAP凭据和数据库连接详情。对于生产环境使用,请实现安全的凭据管理。
- 考虑实现速率限制以避免被标记为垃圾邮件。
[您的许可证信息]