Logging with SMTP Error on Mac

Bev in TX countryone77 at yahoo.com
Fri Aug 21 09:34:04 EDT 2009


Hi,

I've done some Python programming, but I still consider myself a
Python newbie.  I have a Mac Pro OS X 10.5.8 system and I installed
Python 2.6.2 (the latest package available for the Mac) yesterday.

I was working through Matt Wilson's article on using the logging
module:
http://blog.tplus1.com/index.php/2007/09/28/the-python-logging-module-is-much-better-than-print-statements/
(If that does not work, then try: http://tinyurl.com/5v2lcy )

Everything worked great until his last example.  My ISP does not
provide e-mail, so I tried using gmail in the line that sets h2.  I
substituted "mailid" for my actual e-mail address in the following
examples; in my test I used my actual e-mail ID.  Also, I used the
full path to the newly installed Python 2.6.2; otherwise it picked up
the older Python 2.5:
#!/Library/Frameworks/Python.framework/Versions/2.6/bin/python

First attempt:
h2 = logging.handlers.SMTPHandler('smtp.gmail.com', 'mailid at gmail.com',
['mailid at gmail.com'],'ERROR log')
However, that caused the following error to be issued:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/logging/handlers.py", line 868, in emit
    smtp.sendmail(self.fromaddr, self.toaddrs, msg)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/smtplib.py", line 698, in sendmail
    raise SMTPSenderRefused(code, resp, from_addr)
SMTPSenderRefused: (530, '5.7.0 Must issue a STARTTLS command first.
7sm3867994qwf.47', 'mailid at gmail.com')

I also tried providing my gmail userid/password, I tried adding a 5th,
credential, argument, which is a tupple, (username,password) (new in
2.6).

Second attempt:
h2 = logging.handlers.SMTPHandler('smtp.gmail.com', 'mailid at gmail.com',
['mailid at gmail.com'],'ERROR log',('mailid at gmail.com','gmail-
password'))
However, that caused the following error message:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/logging/handlers.py", line 867, in emit
    smtp.login(self.username, self.password)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/smtplib.py", line 552, in login
    raise SMTPException("SMTP AUTH extension not supported by
server.")
SMTPException: SMTP AUTH extension not supported by server.

I am able access gmail via Mac's Mail, in which it says that outgoing
mail is going to:
      smtp.gmail.com:mailid
I tried using that as the server in the Python script, but it could
not find that server.

Is this possible?  If I am doing something incorrectly, would someone
please indicate what it is?

Thanks,
Bev in TX



More information about the Python-list mailing list