I recently tried setting up the PORTAGE_ELOG_MAILURI to work with gmail. After many headaches, I fixed the following problems with it: You need to call an initial ehlo() before the starttls() in order for the starttls() to work. according to the python reference at http://docs.python.org/lib/SMTP-objects.html you need to call another ehlo() after starttls (which is not explicitly done). Without this, logins will not function. Gmail's ssl servers don't close the connection correctly, this causes a crash with error code 8. I added a conditional to ignore that error (probably not the best way) Since I can't seem to attach the patch I made, you can get it at http://www.csh.rit.edu/~russ/portage-elog-mailer.patch
Created attachment 123517 [details, diff] portage-elog-mailer.patch Oh, guess I can attach the patch... done
Thanks for the patch. Is there any particular reason why the patch chooses to ignore the socket.error with errno == 8 (aka errno.ENOEXEC)? I'm just curious because silently ignoring errors is often not a good thing.
When the myconn.close() is called, an error of type 8 is thrown. It seems that gmail's servers don't close the connection correctly, and the only way to fix it is to ignore it.
One thought however, my direct calls to ehlo() may cause problems with servers that support tls and don't support ehlo (is that possible?)
Created attachment 123567 [details, diff] portage-elog-mailer.patch I fixed the patch up a bit. It now includes the following: Comments It throws a warning instead of silently ignoring the error code 8. It now ONLY ignores the error code 8 if it is thrown by the quit() method. Here's a bit of code to check if ehlo is supported and use helo if it is not. I didn't put it in the patch, because i'm not sure if it's necessary in the tls-only case where I use ehlo. #if not (200 <= myconn.ehlo()[0] <= 299): # myconn.helo()
*** Bug 186590 has been marked as a duplicate of this bug. ***
Created attachment 125982 [details, diff] portage-elog-mailer-prepatched.patch I've been getting another error recently. I'm not sure if it is caused by gmail, or if it is my system, however I suspect gmail. To get it working again, it was just a matter of ignoring another error. A patch to a portage_mail.py with my old patches is attached, and I will attach another patch which can be applied to a vanilla portage_mail.py. However once we know the cause better the error message should probably be changed a bit. The error is: ==================================== Error in portage_exec.run_exitfuncs File "/usr/lib/portage/pym/portage_exec.py", line 84, in run_exitfuncs func(*targs, **kargs) File "/usr/lib/portage/pym/elog_modules/mod_mail_summary.py", line 38, in finalize portage_mail.send_mail(mysettings, mymessage) File "/usr/lib/portage/pym/portage_mail.py", line 100, in send_mail raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?") !!! A network error occured while trying to send logmail: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number') Sure you configured PORTAGE_ELOG_MAILURI correctly? ==================================== Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/portage/pym/portage_exec.py", line 84, in run_exitfuncs func(*targs, **kargs) File "/usr/lib/portage/pym/elog_modules/mod_mail_summary.py", line 38, in finalize portage_mail.send_mail(mysettings, mymessage) File "/usr/lib/portage/pym/portage_mail.py", line 100, in send_mail raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?") PortageException: !!! A network error occured while trying to send logmail: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number') Sure you configured PORTAGE_ELOG_MAILURI correctly? Error in sys.exitfunc: Traceback (most recent call last): File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/portage/pym/portage_exec.py", line 84, in run_exitfuncs func(*targs, **kargs) File "/usr/lib/portage/pym/elog_modules/mod_mail_summary.py", line 38, in finalize portage_mail.send_mail(mysettings, mymessage) File "/usr/lib/portage/pym/portage_mail.py", line 100, in send_mail raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?") portage_exception.PortageException: !!! A network error occured while trying to send logmail: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number') Sure you configured PORTAGE_ELOG_MAILURI correctly?
Created attachment 125983 [details, diff] portage-elog-mailer.patch This one can be applied to the vanilla portage_mailer.py
It will be nice if in the portage documentation it was documented that we need to add 100000 to the port number to have TLS auth. New error message: !!! This is an error that I don't know anything about: !!! (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number') !!! This error can probably be ignored.
Yes, that error would cause crashes, but the latest patch tells has it tell you that message and continue. It should work fine.
is it possible to configure ELOG to verify the ssl certificate of the mail server when using TLS?
(In reply to comment #11) > is it possible to configure ELOG to verify the ssl certificate of the mail > server when using TLS? > Um... tls is encrypted. I believe it uses ssl to provide that encryption. Otherwise, i'm not sure what you are asking.
(In reply to comment #11) > is it possible to configure ELOG to verify the ssl certificate of the mail > server when using TLS? No, pythons smtplib module doesn't seem to support that anyway. However if you specify a command (must accept basic sendmail options) instead of a server in the MAILURI variable that command could verify the cerificate.
Handled this in a different way, as the real bug here was that the exception caused a traceback because it was triggered in mod_mail_summary.finalize and not caught by elog_process as it would with mod_mail. So no need to add special cases in the main mail module.
Thanks, this has been released in 2.1.3.13.