Gmail mail server
I used use Google’s slick interface to get my mail and It’s always going to b开发者_运维知识库e here:
https://mail.google.com/a/yourdomainhere.com
I want to write python script that send mail so i failed to configure server settings
smtp = smtplib.SMTP('mail server should be what?', what is the port)
smtp.login('username@yourdomainhere.com', 'pass')
Please could any one help me ??
Thanks
All on gmail's support site, see http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
Look at the help: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
Its smtp.gmail.com
The preferred method for SMTP message forwarding is using your ISP's SMTP server. The job of locating Google's Message transfer agent is handled by such servers.
To use Google's servers directly, you need to look up the MX records provided by google via DNS. From a Python
program, a DNS library is needed. Here is an example, using dnspython
, a A DNS toolkit for Python.
>>> from dns import resolver
>>> mxrecs = resolver.query('gmail.com', 'MX')
>>> [mx for mx in mxrecs]
[<DNS IN MX rdata: 20 alt2.gmail-smtp-in.l.google.com.>,
<DNS IN MX rdata: 40 alt4.gmail-smtp-in.l.google.com.>,
<DNS IN MX rdata: 30 alt3.gmail-smtp-in.l.google.com.>,
<DNS IN MX rdata: 10 alt1.gmail-smtp-in.l.google.com.>,
<DNS IN MX rdata: 5 gmail-smtp-in.l.google.com.>]
>>> mx.exchange.to_text()
'gmail-smtp-in.l.google.com.'
>>> mx.preference
5
>>>
The preferred mail-exchange server here is gmail-smtp-in.l.google.com
, which can be used with smtplib
to forward messages.
精彩评论