Python Forum
I am trying to send an email with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I am trying to send an email with python
#1
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 :[
Reply
#2
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
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#3
(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.
Reply
#4
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.
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#5
This is a directory issue. Make sure you have the path correctly stated in your .py file.
Reply
#6
(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?
Reply
#7
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.
Reply
#8
(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?
Reply
#9
Try restart Pc.
Reply
#10
(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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Send email with smtp without using Mimetext mgallotti 0 677 Feb-01-2023, 04:43 AM
Last Post: mgallotti
  email Library: properly send message as quoted-printable malonn 3 1,264 Nov-14-2022, 09:31 PM
Last Post: malonn
  Unable to send email attachments cosmarchy 7 2,441 Mar-09-2022, 09:29 PM
Last Post: bowlofred
  How to make scraper send email notification just once themech25 0 1,362 Nov-08-2021, 01:51 PM
Last Post: themech25
  send email smtp rwahdan 0 1,754 Jun-19-2021, 01:28 AM
Last Post: rwahdan
  How can I get Python Bulk Email Verification Script With API? zainalee 1 2,460 Jun-06-2021, 09:19 AM
Last Post: snippsat
  Need Outlook send email code using python srikanthpython 3 8,086 Feb-28-2021, 01:53 PM
Last Post: asyswow64
Video Python Bulk Email Verification Script With API Aj1128 0 2,595 Nov-28-2020, 11:38 AM
Last Post: Aj1128
  Sending Out Email via Python JoeDainton123 1 4,699 Aug-31-2020, 12:54 AM
Last Post: nilamo
  How to send email using python? Gigux 2 2,780 Jul-04-2020, 07:53 AM
Last Post: Gigux

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020