Python Forum

Full Version: I am trying to send an email with python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
so i was following a tutorial on YouTube and this is what i ended up with
short and simple code to send a simple email.
import smtplib

server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login("[email protected]", "password")
server.sendmail(
  "[email protected]",
  "[email protected]",
  "this message is from python")
server.quit()
but when I run the program I get these errors
Error:
Traceback (most recent call last): File "C:/Users/me/PycharmProjects/untitled1/123.py", line 3, in <module> server = smtplib.SMTP_SSL('smtp.gmail.com', 465) File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\smtplib.py", line 1031, in __init__ context = ssl._create_stdlib_context(certfile=certfile, File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 801, in _create_unverified_context context.keylog_filename = keylogfile FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\me\\Documents\\Wireshark\\ssl-keys.log'
Im not expert (hence Im here asking for help) but has Wireshark messed up python getting ssl keys?
Ive looked around and I couldn't find a solution or anyone else with this problem so this is my last hope :[
Please use proper code tags while posting your thread.
As the error states - it looks like you are calling either a file you don't have or the wrong file. Just check the file on your computer
(Jun-29-2020, 02:38 PM)pyzyx3qwerty Wrote: [ -> ]Please use proper code tags while posting your thread.
As the error states - it looks like you are calling either a file you don't have or the wrong file. Just check the file on your computer
Hi thanks for replying sorry for not using the needed tags I joined just this morning and do not yet know the ways of this forum. :/
also what file is the right one to call?
sorry for being an annoying ignorant noob but could you walk me through fixing it?
I would be greatly obliged.
It's your computer - I'm not supposed to know what file you are supposed to call. However, to check if it is the right file, just go through the file and see if it meets all your requirements.
This is a directory issue. Make sure you have the path correctly stated in your .py file.
(Jun-29-2020, 04:28 PM)pyzyx3qwerty Wrote: [ -> ]It's your computer - I'm not supposed to know what file you are supposed to call. However, to check if it is the right file, just go through the file and see if it meets all your requirements.
(Jun-29-2020, 04:28 PM)pyzyx3qwerty Wrote: [ -> ]It's your computer - I'm not supposed to know what file you are supposed to call. However, to check if it is the right file, just go through the file and see if it meets all your requirements.
I cut and pasted the file location in the error to the file explorer search and it says the file does not exist. I suppose what I need to do is have it call the correct file? how would I change what file is being called?

(Jun-29-2020, 04:52 PM)HarleyQuin Wrote: [ -> ]This is a directory issue. Make sure you have the path correctly stated in your .py file.
OK that sounds easy enough. :D how do I do that?
When you have used Wireshark before may have setup a log to a environment variable SSLKEYLOGFILE.
Test with.
>>> import os
>>> 
>>> key = os.environ.get('SSLKEYLOGFILE')
>>> repr(key)
'None'
As you see a have no key and have tested code you posted and it work.
So may need to into Environment Variables Path and remove that SSLKEYLOGFILE variable,then try again.
(Jun-29-2020, 05:17 PM)snippsat Wrote: [ -> ]When you have used Wireshark before may have setup a log to a environment variable SSLKEYLOGFILE.
Test with.
>>> import os
>>> 
>>> key = os.environ.get('SSLKEYLOGFILE')
>>> repr(key)
'None'
As you see a have no key and have tested code you posted and it work.
So may need to into Environment Variables Path and remove that SSLKEYLOGFILE variable,then try again.
thanks for the help! I did have an SSLKEYLOGFILE variable which I deleted but I still get the same error I went to system properties>Environment Variables>user Variables and found the SSLKEYLOGFILE and hit the delete button under it. It was deleted and I went back to the code but got the same error.
when I ran the code you provided
>>> import os
>>> 
>>> key = os.environ.get('SSLKEYLOGFILE')
>>> repr(key)
'None'
I still got the same path. Did I delete it incorrectly?
Try restart Pc.
(Jun-29-2020, 06:33 PM)snippsat Wrote: [ -> ]Try restart Pc.
(Jun-29-2020, 06:33 PM)snippsat Wrote: [ -> ]Try restart Pc.
It works now! thank you for all your help! am I supposed to mark this thread as answered now or somthing? or am I good to go?