I’m having trouble with email delivery using Mailgun’s API in my .NET Core application.
The strange thing is that everything works perfectly when I run the app locally on my development machine. Emails go through without any problems. But when I deploy the same code to my production server, I keep getting an SSL connection error.
The exact error message says that the SSL connection could not be established. I’ve been trying to figure out if this is related to my server configuration, something with Mailgun itself, or maybe even my Cloudflare setup.
Has anyone run into this kind of problem before? I’ve been stuck on this for several days now and I’m running out of ideas. Any suggestions would be really helpful.
I encountered a similar issue with Mailgun’s API not connecting due to SSL errors. In my case, it turned out my server was not configured to support the necessary TLS version for secure connections. I resolved this by ensuring my server was set to use TLS 1.2 specifically. Additionally, it’s crucial to verify that your firewall settings permit outbound connections on ports 587 or 465, as these are essential for Mailgun’s functionality. Implementing these changes should help address the SSL connection issue.
Had this exact issue a few months back. It was a certificate validation problem on my production server. Try adding this to bypass cert validation temporarily: ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, sslPolicyErrors) => true; If that fixes it, you know it’s cert-related and you’ll need to properly configure your SSL certs.
Sounds like a network issue with your production environment. I’ve hit this before - my hosting provider was blocking outbound HTTPS connections to certain APIs by default. Check if your production server can actually reach Mailgun’s endpoints. Run curl or telnet tests directly to the Mailgun API from your production server. Also look for proxy settings or network restrictions that might mess with the SSL handshake. Production environments often have different network configs that break SSL even when the same code works fine locally.