{"id":51343358,"url":"https://github.com/yorch-codes/mua_api","last_synced_at":"2026-07-02T09:33:54.292Z","repository":{"id":323580984,"uuid":"1032912536","full_name":"yorch-codes/mua_api","owner":"yorch-codes","description":"Flask API for handling newsletter subscriptions with MailerLite and contact form submissions via SMTP. Built with Python, Pydantic, and Docker-ready for production.","archived":false,"fork":false,"pushed_at":"2025-11-18T19:28:16.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-20T05:28:34.952Z","etag":null,"topics":["api","flask","mailerlite","python","smtp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yorch-codes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-06T02:59:51.000Z","updated_at":"2025-11-18T19:28:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yorch-codes/mua_api","commit_stats":null,"previous_names":["yorchwebs/mua_api","yorchdigitalmx/mua_api","yorch-codes/mua_api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/yorch-codes/mua_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorch-codes%2Fmua_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorch-codes%2Fmua_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorch-codes%2Fmua_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorch-codes%2Fmua_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yorch-codes","download_url":"https://codeload.github.com/yorch-codes/mua_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorch-codes%2Fmua_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35041997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","flask","mailerlite","python","smtp"],"created_at":"2026-07-02T09:33:52.954Z","updated_at":"2026-07-02T09:33:54.279Z","avatar_url":"https://github.com/yorch-codes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MUA API\n\n[![Python Version](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/)\n[![Flask Version](https://img.shields.io/badge/flask-3.1-blue.svg)](https://flask.palletsprojects.com/)\n[![Postman Docs](https://img.shields.io/badge/docs-Postman-orange?logo=postman)](https://documenter.getpostman.com/view/33534242/2sB3WtrySp)\n\nA simple and robust Flask API to handle newsletter subscriptions with MailerLite and contact form submissions via SMTP.\n\n---\n\n## Features\n\n- **Newsletter Subscription:** `/subscribe` endpoint to add users to a MailerLite mailing list.\n- **Contact Form:** `/contact` endpoint to send contact form data via SMTP.\n- **Validation:** Uses Pydantic for request data validation.\n- **Configuration:** Manages settings with `python-decouple` for easy environment-based configuration.\n- **CORS Support:** Enabled globally for development.\n- **Containerization:** Docker support for easy deployment.\n\n---\n\n## CORS Configuration\n\nCORS is currently enabled for all origins (`*`) to simplify local development.\n**⚠️ In production, this should be restricted** to the specific domain(s) that will consume the API — for example:\n\n```python\nfrom flask_cors import CORS\n\nCORS(app, origins=[\"https://yourfrontenddomain.com\"])\n```\n\nThis helps prevent unauthorized cross-origin requests and improves your API’s security.\n\n### Getting Started\n\nPrerequisites\nPython 3.12+\n\nDocker (optional, for containerized deployment)\n\n---\n\n## Installation\n\n### Clone the repository\n\n```bash\ngit clone https://github.com/yorchwebs/mua-api.git\ncd mua-api\n```\n\n### Create and activate a virtual environment\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate\n```\n\n### Install dependencies\n\n```bash\npip install -r requirements-dev.txt\n```\n\n### Configuration\n\nCreate a .env file in the root of the project and add the following environment variables:\n\n```bash\n# MailerLite Configuration\nMAILERLITE_API_KEY=your_mailerlite_api_key\nMAILERLITE_GROUP_ID=your_mailerlite_group_id\n\n# SMTP Configuration\nSMTP_HOST=your_smtp_host\nSMTP_PORT=your_smtp_port\nSMTP_USER=your_smtp_user\nSMTP_PASSWORD=your_smtp_password\nSMTP_FROM=your_smtp_from_address\nSMTP_TO=your_smtp_to_address\n```\n---\n\n## Email Setup Guide\n\nYou can configure the API to send emails using Gmail SMTP or a custom domain.\n\n### 🔹 Using Gmail\n- Go to your Google Account → Security section.\n\n- Enable 2-Step Verification (required to use App Passwords).\n\n- Generate an App Password for “Mail”.\n\n- Use the following configuration in your .env file:\n\n```bash\nSMTP_HOST=smtp.gmail.com\nSMTP_PORT=587\nSMTP_USER=your_email@gmail.com\nSMTP_PASSWORD=your_generated_app_password\nSMTP_FROM=your_email@gmail.com\nSMTP_TO=destination_email@example.com\n```\n\n**⚠️ Regular Gmail passwords won’t work — App Passwords are required.**\n\n---\n\n### 🔹 Using a Custom Domain (e.g., via your hosting provider)\n\n- Locate your domain’s email service settings (e.g., Zoho, Outlook, Namecheap, Hostinger, etc.).\n\n- Obtain the SMTP details (host, port, username, and password).\n\n- Add SPF and DKIM records to your DNS for better deliverability.\n\n- Update your .env file with your domain’s details, for example:\n\n```bash\nSMTP_HOST=mail.yourdomain.com\nSMTP_PORT=587\nSMTP_USER=contact@yourdomain.com\nSMTP_PASSWORD=your_password\nSMTP_FROM=contact@yourdomain.com\nSMTP_TO=support@yourdomain.com\n```\n\n- Running the Application\n- Local Development\n- Run the application in development mode:\n\n```bash\npython run.py\n```\n\nThe application will be available at:\n\n```bash\nhttp://127.0.0.1:5000\n```\n\n---\n\n## Production with Docker\n\nBuild the Docker image\n\n```bash\n# Copiar código\ndocker build -t mua-api .\n```\n\nRun the Docker container\n\n```bash\n# Copiar código\ndocker run -p 8080:8080 --env-file .env mua-api\n```\n\nThe application will be available at:\n\n```bash\n# Copiar código\nhttp://0.0.0.0:8080\n```\n\n---\n\n## API Endpoints\n\n/subscribe\n\nMethod: POST\n\nDescription: Subscribes a user to the MailerLite mailing list.\n\nRequest Body:\n\n```json\n{\n  \"email\": \"user@example.com\"\n}\n```\n\nResponses:\n\n**200 OK:** Subscription successful.\n\n**422 Unprocessable Entity:** Invalid input data.\n\n**400 Bad Request:** Error from MailerLite API.\n\n---\n\n/contact\n\nMethod: POST\n\nDescription: Sends a contact form submission via SMTP.\n\nRequest Body:\n\n```json\n{\n  \"name\": \"John Doe\",\n  \"email\": \"john.doe@example.com\",\n  \"phone\": \"123-456-7890\",\n  \"message\": \"This is a test message.\"\n}\n```\n\nResponses:\n\n**200 OK:** Email sent successfully.\n\n**400 Bad Request:** Missing required fields.\n\n**500 Internal Server Error:** Error sending the email.\n\n---\n\n## Postman API Documentation\n\nInteractive API documentation is available via Postman:\n\n[![Postman Docs](https://img.shields.io/badge/docs-Postman-orange?logo=postman)](https://documenter.getpostman.com/view/33534242/2sB3WtrySp)\n\nThis documentation includes:\n\n- Example requests and responses.\n\n- The ability to test endpoints directly.\n\n- A “Run in Postman” button for easy import.\n\n---\n\n## Testing\nTo run the test suite, use the following command:\n\n```bash\n# Copiar código\npytest\n```\n\n---\n\n## Dependencies\n\nProduction:\n\n- Flask\n\n- Flask-Cors\n\n- gunicorn\n\n- pydantic\n\n- python-decouple\n\n- requests\n\nDevelopment\n\n- pytest\n\nand all production dependencies.\n\nSee requirements-prod.txt and requirements-dev.txt for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyorch-codes%2Fmua_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyorch-codes%2Fmua_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyorch-codes%2Fmua_api/lists"}