Roger Haase wrote:
> I have some suggested changes to /WebKit/ExceptionHandler.py that fix
> problems I recently encountered while sending out email messages for
> servlet tracebacks.
>
> The problems started when my ISP changed the requirements for sending
> out mail via smtp. They went from no login required to a pop3 login
> required -- logging on to pop3 seems to allow emails to be sent via
> smtp for the next hour. The example below shows an attempt to initiate
> a connection without a pop3 login (this is a local cable company so an
> indirect connection will probably result in different errors).
Right, Webware currently support only SMTP-Auth, not SMTP-After-POP. I'm
amazed that this is still used by your ISP. Most ISPs have switched to
SMTP-Auth. Anyway, thanks for the implementation, I'll probably add this
to the next Webware version. I'll also have a look at the issue with
Google mail.
-- Christoph

Thread view

I have some suggested changes to /WebKit/ExceptionHandler.py that fix
problems I recently encountered while sending out email messages for
servlet tracebacks.
The problems started when my ISP changed the requirements for sending
out mail via smtp. They went from no login required to a pop3 login
required -- logging on to pop3 seems to allow emails to be sent via
smtp for the next hour. The example below shows an attempt to initiate
a connection without a pop3 login (this is a local cable company so an
indirect connection will probably result in different errors).
'''
>>> import smtplib
>>> server = smtplib.SMTP('smtp.coxmail.com',25)
Traceback (most recent call last):
File "<pyshell#41>", line 1, in <module>
server = smtplib.SMTP('smtp.coxmail.com',25)
File "c:\Python25\lib\smtplib.py", line 246, in __init__
raise SMTPConnectError(code, msg)
SMTPConnectError: (421, 'Sorry, you must log in before using this
server.')
'''
While trying to figure out that problem, I tried using google mail.
But I found out that gmail requires a starttls() call before login.
Also, gmail and the Python smtplib seem to be presently incompatible
with quit(). Replacing the server.noop() with a login and sendmail in
the example below will get the user logged in and the message sent OK,
but the same error will occur on the quit().
'''
>>> import smtplib
>>> server = smtplib.SMTP('smtp.gmail.com',25)
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES')
>>> server.starttls()
(220, '2.0.0 Ready to start TLS')
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nAUTH LOGIN PLAIN\nENHANCEDSTATUSCODES')
>>> server.noop()
(250, '2.0.0 OK')
>>> server.quit()
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
server.quit()
File "c:\Python25\lib\smtplib.py", line 716, in quit
self.docmd("quit")
File "c:\Python25\lib\smtplib.py", line 378, in docmd
return self.getreply()
File "c:\Python25\lib\smtplib.py", line 352, in getreply
line = self.file.readline()
File "c:\Python25\lib\smtplib.py", line 160, in readline
chr = self.sslobj.read(1)
sslerror: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong
version number')
'''
Finally, the existing code resulted in no response after my pop3-smtp
failures and the user was left waiting for the browser to timeout.
The changes I made to the emailException method follow. In Webware
9.4, this replaces everything after "# Send the message" on line 571 to
the end of the method. This has only been tested with my ISP's curious
pop3 login and gmail. The "self._res.flush()" could be better placed
in the calling method. The "import poplib" should probably go at the
top of the module with the other imports.
'''
# Send the message
self._res.flush() # do not make user wait for email
settings = self.setting('ErrorEmailServer')
# this setting can be: server, server:port,
server:port:user:password,server:port:user:password:pop3server
parts = settings.split(':', 4)
server = user = password = pop3Server = None
port = 25
try:
# assign passed values, ignore the rest
server = parts[0]
port = int(parts[1])
user = parts[2]
password = parts[3]
pop3Server = parts[4]
except:
pass
try:
# if there is a failure, don't bother the user, fail
silently
if pop3Server:
# some mail servers require login to pop3 rather than
smtp
import poplib
pop3 = poplib.POP3(pop3Server)
pop3.user(user)
pop3.pass_(password)
pop3.quit()
server = smtplib.SMTP(server,port)
elif password:
# some mail servers require login to smtp
server = smtplib.SMTP(server,port)
server.ehlo()
if server.has_extn('starttls'):
# some servers require a secure login
server.starttls()
server.ehlo()
server.login(user, password)
else:
# some mail servers do not require login
server = smtplib.SMTP(server,port)
# server.set_debuglevel(1)
server.sendmail(headers['From'], headers['To'],
message.getvalue())
server.quit()
except:
pass
return
'''
Roger Haase
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/

Roger Haase wrote:
> I have some suggested changes to /WebKit/ExceptionHandler.py that fix
> problems I recently encountered while sending out email messages for
> servlet tracebacks.
>
> The problems started when my ISP changed the requirements for sending
> out mail via smtp. They went from no login required to a pop3 login
> required -- logging on to pop3 seems to allow emails to be sent via
> smtp for the next hour. The example below shows an attempt to initiate
> a connection without a pop3 login (this is a local cable company so an
> indirect connection will probably result in different errors).
Right, Webware currently support only SMTP-Auth, not SMTP-After-POP. I'm
amazed that this is still used by your ISP. Most ISPs have switched to
SMTP-Auth. Anyway, thanks for the implementation, I'll probably add this
to the next Webware version. I'll also have a look at the issue with
Google mail.
-- Christoph

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details