tags:

views:

135

answers:

3

Hello,

I used use Google’s slick interface to get my mail and It’s always going to be 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('[email protected]', 'pass')

Please could any one help me ??

Thanks

+3  A: 

All on gmail's support site, see http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

Donnie
I tried smtp = smtplib.SMTP('smtp.gmail.com',587) smtp.login('[email protected]', 'pass')i got the following error " raise SMTPException("SMTP AUTH extension not supported by server.") SMTPException: SMTP AUTH extension not supported by server."
Neveen
If you had read the link you'd see that you must use TLS or SSL. I believe SMTPlib supports TLS, so you should be ok, as long as you start the TLS session.
Donnie
Thanks a lot for your help.But how can i start a TLS session ?
Neveen
A: 

Look at the help: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

Its smtp.gmail.com

Marks
A: 

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.

gimel