So this is the email setup:

    import ssl
    import smtplib

    port = 465  # For SSL
    smtp_server = "smtp.gmail.com"
    sender_email = "[email protected]"
    receiver_email = "[email protected]"
    password = "password"

    message = f"""\
    Subject: Email Sent from Blender on MacOS
    This Email was sent from Python in Blender on MacOS.

    context = ssl.create_default_context()
    with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
        server.login(sender_email, password)
        server.sendmail(sender_email, receiver_email, message)

Pretty easy, nothing special. When running this in Python 3.10 on my machine I receive the email and all is good.

But then this error message appears when I run this code as a script in Blenders IDE:

location: <unknown location>:-1
Error: Python: Traceback (most recent call last):
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/smtplib.py", line 1050, in __init__
    SMTP.__init__(self, host, port, local_hostname, timeout,
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/smtplib.py", line 341, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/smtplib.py", line 1057, in _get_socket
    new_socket = self.context.wrap_socket(new_socket,
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/ssl.py", line 1070, in _create
  File "/Applications/Blender.app/Contents/Resources/3.1/python/lib/python3.10/ssl.py", line 1341, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

So why is this happening? Well as far as I can tell this is the solution: On your Mac go to Macintosh HD > Applications > Python3.## then run the file Install Certificates.command. And this fixed the issue for me when running a normal Python interpreter using say Pycharm.

As far as I can tell Install Certificates.command is no where to be found inside the Blender internal Python version. My question is, how do I generate valid SSL certificates inside Blenders Python version without the Install Certificates.command file?

All I want to do is send emails from Blender. Thank you for reading and for your time!

  • $\begingroup$ can you try this? exerror.com/… $\endgroup$
    – Harry McKenzie
    Commented Jun 19, 2022 at 2:39
  • 1
    $\begingroup$ Could your problem be solved? I would be grateful for feedback. $\endgroup$
    – quellenform
    Commented Jun 30, 2022 at 16:41

1 Answer 1


As @HarryMcKenzie correctly mentioned in the comment, the library to verify the SSL certificate seems to be missing.

However, as far as I know, you would have to install additional Python libraries in this way so that you can use them directly in Blender:

# Navigate to the installation directory
cd /Applications/Blender.app/Contents/Resources/3.1/python/bin/
# Use blender's bundled python & install/upgrade the package
python -m ensurepip
python -m pip install --upgrade certifi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .