duanjiong1952 2015-06-24 04:44
浏览 50

我用什么作为SMTP

I am trying to write a Python script to send an email from my server, now from my research the first thing I see is I have to set server = smtplib.SMTP('server?', 25) and were server? is Im not sure what to put I have seen smtp.gmail.com and I have seen localhost, Ideally I want send the email form my Gmail account so I think I want smtp.gmail.com but when I have that I get this error

Traceback (most recent call last):
 File "/home/jam/public_html/cgi-bin/email.py", line 6, in <module>
   server = smtplib.SMTP('smtp.gmail.com', 25)
 File "/usr/lib64/python2.6/smtplib.py", line 239, in __init__
   (code, msg) = self.connect(host, port)
 File "/usr/lib64/python2.6/smtplib.py", line 295, in connect
   self.sock = self._get_socket(host, port, self.timeout)
 File "/usr/lib64/python2.6/smtplib.py", line 273, in _get_socket
   return socket.create_connection((port, host), timeout)
 File "/usr/lib64/python2.6/socket.py", line 567, in create_connection
   raise error, msg
socket.error: [Errno 101] Network is unreachable

So what is supposed to go there?

Thanks for the help :)

  • 写回答

3条回答 默认 最新

  • dqwh0109 2015-06-24 04:48
    关注

    ISSUE:

    First of all you are using gmail server to send mail .For gmail server the output port is 587

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)