Cursor email

SMTP Connection Refused in Production for Cursor-Generated Email Code

Your Cursor-generated application sends emails perfectly during local development but fails with SMTP connection errors in production. Users aren't receiving signup confirmations, password resets, or notification emails. The server logs show connection refused, timeout, or authentication errors when attempting to connect to the mail server.

Email delivery is critical infrastructure — when it breaks, users can't sign up, can't reset passwords, and lose trust in your application. Cursor often generates SMTP code configured for a local mail server or development service like Mailtrap/Mailhog, which doesn't translate to production.

The issue might also manifest as emails being sent successfully according to your application logs, but never arriving in users' inboxes due to DNS, SPF, or deliverability configuration problems that only affect production domains.

Error Messages You Might See

Error: connect ECONNREFUSED 127.0.0.1:25 Error: connect ETIMEDOUT smtp.gmail.com:587 Error: Invalid login: 535 5.7.8 Authentication failed Error: self signed certificate in certificate chain getaddrinfo ENOTFOUND smtp.mailtrap.io
Error: connect ECONNREFUSED 127.0.0.1:25Error: connect ETIMEDOUT smtp.gmail.com:587Error: Invalid login: 535 5.7.8 Authentication failedError: self signed certificate in certificate chaingetaddrinfo ENOTFOUND smtp.mailtrap.io

Common Causes

  • Port 25 blocked by cloud provider — AWS, GCP, Azure, and most cloud providers block outbound SMTP port 25 by default to prevent spam. You need to use port 587 (STARTTLS) or 465 (SSL/TLS)
  • Development SMTP credentials in production — Cursor configured Mailtrap, Mailhog, or localhost:1025 credentials that only work in development
  • Missing or wrong TLS/SSL configuration — Production SMTP servers require TLS encryption but the code uses plain text connections, or uses SSL when STARTTLS is expected
  • Firewall or security group blocking outbound — The production server's security group or network ACL doesn't allow outbound connections on port 587 or 465
  • SMTP authentication method mismatch — The email provider requires OAuth2 authentication (like Gmail) but the code uses plain username/password
  • DNS resolution failing for SMTP host — The SMTP hostname can't be resolved from the production environment due to internal DNS or networking constraints

How to Fix It

  1. Use port 587 with STARTTLS — Configure your SMTP connection to use port 587 with STARTTLS encryption. This is the standard for authenticated email submission and is not blocked by cloud providers
  2. Switch to an email API service — Replace SMTP with an HTTP-based email API like SendGrid, Resend, Postmark, or AWS SES. These are more reliable than SMTP in serverless/cloud environments and include deliverability features
  3. Verify production environment variables — Check that SMTP_HOST, SMTP_PORT, SMTP_USER, and SMTP_PASS are set correctly in your production environment, not pointing to development values
  4. Check cloud provider email restrictions — If on AWS, you may need to request removal of the port 25 throttle. On most providers, using SES or a third-party email API is the recommended approach
  5. Test SMTP connectivity from production — SSH into your production server and run openssl s_client -connect smtp.provider.com:587 -starttls smtp to verify the connection is possible
  6. Configure SPF, DKIM, and DMARC — Even if SMTP connects, emails may be rejected without proper DNS records for your sending domain

Real developers can help you.

Caio Rodrigues Caio Rodrigues I'm a full-stack developer focused on building practical and scalable web applications. My main experience is with **React, TypeScript, and modern frontend architectures**, where I prioritize clean code, component reusability, and maintainable project structures. I have strong experience working with **dynamic forms, state management (Redux / React Hook Form), and complex data-driven interfaces**. I enjoy solving real-world problems by turning ideas into reliable software that companies can actually use in their daily operations. Beyond coding, I care about **software quality and architecture**, following best practices for componentization, code organization, and performance optimization. I'm also comfortable working across the stack when needed, integrating APIs, handling business logic, and helping transform prototypes into production-ready systems. My goal is always to deliver solutions that are **simple, efficient, and genuinely useful for the people using them.** Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: 💡 Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. 🖋️ Sharing insights through technical writing, blogging, and open-source contributions. 🤝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. 🚀 Launched Compose101 — a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart 🎖️ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. Matt Butler Matt Butler Software Engineer @ AWS Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Basel Issmail Basel Issmail ’m a Senior Full-Stack Developer and Tech Lead with experience designing and building scalable web platforms. I work across the full development lifecycle, from translating business requirements into technical architecture to delivering reliable production systems. My work focuses on modern web technologies, including TypeScript, Angular, Node.js, and cloud-based architectures. I enjoy solving complex technical problems and helping teams turn product ideas and prototypes into working platforms that can grow and scale. In addition to development, I often collaborate closely with product managers, business analysts, designers, and QA teams to ensure that solutions align with both technical and business goals. I enjoy working with startups and product teams where I can contribute both as a hands-on engineer and as a technical partner in designing and delivering impactful software. Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Why does email work locally but not in production?

Local development often uses a local SMTP server (Mailhog, Mailtrap) or your machine has no firewall restrictions. Production environments block port 25, require TLS, and need real SMTP credentials. Switch to an email API service like SendGrid or Resend for reliable production email.

Should I use SMTP or an email API?

For production apps, use an HTTP-based email API (SendGrid, Resend, Postmark, AWS SES). They're more reliable than SMTP in cloud/serverless environments, handle retries automatically, and include deliverability monitoring and analytics.

Related Cursor Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help