Issue Deploying Django Project on cPanel: Certificate Verification Error
I am facing an issue while deploying my Django project on cPanel. The error indicates a certificate verification problem with the SMTP server 'smtp.gmail.com'. I have tried various solutions found online, but the issue persists.
Here is my email configuration in settings.py:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '***'
EMAIL_HOST_PASSWORD = '***'
EMAIL_PORT = 587
Despite trying different solutions, I continue to receive the following error:
csharp certificate verify failed: Hostname mismatch, certificate is not valid for 'smtp.gmail.com'. (_ssl.c:1007) I also attempted to create a custom EMAIL_BACKEND with the following code:
import ssl
from django.core.mail.backends.smtp import EmailBackend as SMTPBackend
from django.utils.functional import cached_property
class EmailBackend(SMTPBackend):
@cached_property
def ssl_context(self):
if self.ssl_certfile or self.ssl_keyfile:
ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_cert_chain(self.ssl_certfile, self.ssl_keyfile)
return ssl_context
else:
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
return ssl_context
However, this resulted in the error:
bash code 535, b'Incorrect authentication data' I also attempted to use GPT, but did not find any useful resources.
The output from the openssl s_client command indicates a successful SSL handshake, but the common name (CN) in the server certificate is listed as grace.mysecurecloudserver.com, not smtp.gmail.com.
Is there a problem with my configuration, code, or cPanel setup? Any guidance on resolving this issue would be greatly appreciated. Thank you!