Error :
PS C:\Ashish> & "C:/Program Files/Python39/python.exe" c:/Folder/SendEmail.py
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\urllib\request.py", line 1346, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\Python39\lib\http\client.py", line 1279, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\Python39\lib\http\client.py", line 1325, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\Python39\lib\http\client.py", line 1274, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\Python39\lib\http\client.py", line 1034, in _send_output
self.send(msg)
File "C:\Program Files\Python39\lib\http\client.py", line 974, in send
self.connect()
File "C:\Program Files\Python39\lib\http\client.py", line 1448, in connect
self.sock = self._context.wrap_socket(self.sock,
File "C:\Program Files\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Program Files\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Program Files\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Ashish\Send.py", line 26, in <module>
response = sg.send(message)
File "C:\Program Files\Python39\lib\site-packages\sendgrid\base_interface.py", line 62, in send
return self.client.mail.send.post(request_body=message)
File "C:\Program Files\Python39\lib\site-packages\python_http_client\client.py", line 277, in http_request
self._make_request(opener, request, timeout=timeout)
File "C:\Program Files\Python39\lib\site-packages\python_http_client\client.py", line 176, in _make_request
return opener.open(request, timeout=timeout)
File "C:\Program Files\Python39\lib\urllib\request.py", line 517, in open
response = self._open(req, data)
File "C:\Program Files\Python39\lib\urllib\request.py", line 534, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Program Files\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "C:\Program Files\Python39\lib\urllib\request.py", line 1389, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "C:\Program Files\Python39\lib\urllib\request.py", line 1349, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)>
Issue :
Sendgrid Certificate Chain is not valid in Windows Certificate Store. You can check it by visiting Sendgrid.com website from Windows Server.
Solution :
Goto https://certs.godaddy.com/repository
1. Download G2 Certificate
2. Install it in Trusted Root Authority Store.
3. After installation, the root certificate should show OK.