我正在编写一个脚本,用于发送我公司的邮件,主机是IP,所以我试图以这种方式连接(也尝试过其他人),但没有......
这是我的代码:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import commands
import sys
import smtplib # Librería envío de reporte
#Datos de envio
correo_emisor = "mail"
correo_receptor = "mail"
msg = "Correo de prueba"
psw_correo = "pwd"
#Conexion servidor de correo
try:
print "Conectando..."
servidor_correo = smtplib.SMTP("217.28.130.90", port=587)
#servidor_correo = SMTP()
#servidor_correo.connect("217.28.130.90", 587)
servidor_correo.ehlo()
servidor_correo.starttls()
servidor_correo.ehlo()
print "Conexion exitosa a servidor de correo..."
#Datos para envio de correo
servidor_correo.login(correo_emisor,psw_correo)
except smtplib.SMTPConnectError as e:
print (str(e))
sys.exit()
#Contenido de correo
asunto = "Correo de prueba"
servidor_correo.strip(asunto)
try:
servidor_correo.sendmail(correo_emisor, correo_receptor, msg)
except smtplib.SMTPException:
print "El correo no se pudo enviar"
servidor_correo.close()
sys.exit()
我有下一个错误:
[informix@informix_vm_01 pruebas_correo]$ ./Test.py
Conectando...
Traceback (most recent call last):
File "./Test.py", line 24, in <module>
servidor_correo = smtplib.SMTP("217.28.130.90:587")
File "/usr/lib64/python2.7/smtplib.py", line 255, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib64/python2.7/smtplib.py", line 315, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib64/python2.7/smtplib.py", line 290, in _get_socket
return socket.create_connection((host, port), timeout)
File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
raise err
socket.error: [Errno 110] Connection timed out
我已经尝试过不同的方法来解决它但没有任何方法!