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.

Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. Alvin Voo Alvin Voo I’ve watched the tech landscape evolve over the last decade—from the structured days of Java Server Pages to the current "wild west" of Agentic-driven development. While AI can "vibe" a frontend into existence, I specialize in the architecture that keeps it from collapsing. My expertise lies in the critical backend infrastructure: the parts that must be fast, secure, and scalable. I thrive on high-pressure environments, such as when I had only three weeks to architect and launch an Ethereum redemption system with minimal prior crypto knowledge, turning it into a major revenue stream. What I bring to your project: Forensic Debugging: I don't just "patch" bugs; I use tools like Datadog and Explain Analyzers to map out bottlenecks and resolve root causes—like significantly reducing memory usage by optimizing complex DB joins. Full-Stack Context: Deep experience in Node.js and React, ensuring backends play perfectly with mobile and web teams. Sanity in the Age of AI: I bridge the gap between "best practices" and modern speed, ensuring your project isn't just built fast, but built to last. David Olverson David Olverson Solo dev shipping production apps with AI-assisted development. I specialize in rescuing broken Lovable/Bolt/Cursor builds and taking them to production. 10+ apps shipped including SaaS CRMs, gaming platforms, real estate tools, and Discord bots. Stack: Next.js 16, TypeScript, Tailwind CSS, FastAPI, PostgreSQL, Prisma. I use Claude Code with 50+ custom skills for rapid delivery. Average turnaround: 2-4 weeks from broken prototype to production. 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. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Omar Faruk Omar Faruk As a Product Engineer at Klasio, I contributed to end-to-end product development, focusing on scalability, performance, and user experience. My work spanned building and refining core features, developing dynamic website templates, integrating secure and reliable payment gateways, and optimizing the overall system architecture. I played a key role in creating a scalable and maintainable platform to support educators and learners globally. I'm enthusiastic about embracing new challenges and making meaningful contributions.

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