I try to send email thanks to a python script and it's not working. I tried different mail adresses (Hotmail and Gmail), different ports, etc. none is working and I always have the same adress even if I just write two lines of code. I also try Latin-1 or utf-8 encoding...nothing change!
I am working with anaconda and python 3.6 on windows10.
Code :
import smtplib
serveur = smtplib.SMTP('smtp.gmail.com',587)
And the error :
runfile('C:/Users/Come/AppData/Roaming/Microsoft/Windows/Network Shortcuts/sanstitre3.py', wdir='C:/Users/Come/AppData/Roaming/Microsoft/Windows/Network Shortcuts')
Traceback (most recent call last):
File "<ipython-input-1-a733f02e7871>", line 1, in <module>
runfile('C:/Users/Come/AppData/Roaming/Microsoft/Windows/Network Shortcuts/sanstitre3.py', wdir='C:/Users/Come/AppData/Roaming/Microsoft/Windows/Network Shortcuts')
File "D:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "D:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Come/AppData/Roaming/Microsoft/Windows/Network Shortcuts/sanstitre3.py", line 9, in <module>
serveur = smtplib.SMTP('smtp.gmail.com',587)
File "D:\Anaconda\lib\smtplib.py", line 261, in __init__
fqdn = socket.getfqdn()
File "D:\Anaconda\lib\socket.py", line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf4 in position 1: invalid continuation byte
EDIT :
So far I tried differnt things but Nothing worked :
no my code begin like :
# -*- coding:Latin-1 -*-
import smtplib
import socket
hostname, aliases, ipaddrs = socket.gethostbyaddr('smtp.gmail.com')
socket.getfqdn()
socket.gethostname()
serveur = smtplib.SMTP("smtp.gmail.com",587)
serveur.ehlo()
I also ping smtp.gmail.com, here is the result, all seem in order... but it's still not working (I also checked if any specific characters weren't in my files names)
Envoi d’une requête 'ping' sur gmail-smtp-msa.l.google.com [74.125.206.108] avec 32 octets de données :
Réponse de 74.125.206.108 : octets=32 temps=8 ms TTL=47
Réponse de 74.125.206.108 : octets=32 temps=7 ms TTL=47
Réponse de 74.125.206.108 : octets=32 temps=7 ms TTL=47
Réponse de 74.125.206.108 : octets=32 temps=6 ms TTL=47
Statistiques Ping pour 74.125.206.108:
Paquets : envoyés = 4, reçus = 4, perdus = 0 (perte 0%),
Durée approximative des boucles en millisecondes :
Minimum = 6ms, Maximum = 8ms, Moyenne = 7ms
Finally I don't think the error comes from the message because so far it's just "my message"...
EDIT 2 :
I may have found the problem but I don't know how to solve it!
if I write directly those lines :
In[59]: import socket
In[60]: socket.gethostname()
Out[60]: 'Côme'
I can see there is a problem with the hostname... but I don't know how to change it.