我用什么作为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 :)

ISSUE:

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

To send email from your Gmail account, you can use Gmail's SMTP server per this Google Administrator Help page: Google Apps SMTP settings to send mail from a printer, scanner, or app

The following configuration requirements are provided for SMTP via smtp.gmail.com.

  • Port 465 (SSL required)
  • Port 587 (TLS required)
  • Dynamic IPs allowed

In python, please download yagmail (disclaimer: I'm the developer):

pip install yagmail

It is then simply a matter of:

import yagmail
yag = yagmail.SMTP('me@gmail.com', 'mypassword')
yag.send('to@gmail.com', 'This is the subject', 'This is the body')

On the github you can also see a common list of errors.