Ask Your Question
0

Can't make email connection doing a Mail Merge in Writer

asked 2017-09-22 00:18:49 +0200

Jonathan MPS LTD gravatar image

updated 2017-09-22 13:25:03 +0200

I'm on Windows 10, LO 5.4.1.2

I'm trying to do an email mail merge from writer but the test settings option always fails.

The mail settings I'm using are correct (servername, username & password) they are same as my email client

Error:

LibreOffice could not connect to the outgoing mail server. Check your system's settings and the settings in LibreOffice. Check the server name, the port and the secure connections settings
--
<class 'smtplib.SMTPServerDisconnected'>: Connection unexpectedly closed: [WinError 10054] 
An existing connection was forcibly closed by the remote host, traceback follows
  File "C:\Program Files (x86)\LibreOffice 5\program\mailmerge.py", line 107, in connect self.server = smtplib.SMTP(server, port,timeout=tout)
  File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.5.0\lib\smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.5.0\lib\smtplib.py", line 338, in connect
    (code, msg) = self.getreply()
  File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.5.0\lib\smtplib.py", line 391, in getreply
    + str(e))

When I try Port 587 as suggested by earlier threads I get:

LibreOffice could not connect to the outgoing mail server. Check your system's settings and the settings in LibreOffice. Check the server name, the port and the secure connections settings

<class 'runtimeerror'="">: No SSL support included in this Python, traceback follows File "C:\Program Files (x86)\LibreOffice 5\program\mailmerge.py", line 121, in connect self.server.starttls() File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.5.0\lib\smtplib.py", line 756, in starttls raise RuntimeError("No SSL support included in this Python")

edit retag flag offensive close merge delete

Comments

Did you also check the port setting in LO config?

robleyd gravatar imagerobleyd ( 2017-09-22 02:16:23 +0200 )edit

Yes, port 465

Jonathan MPS LTD gravatar imageJonathan MPS LTD ( 2017-09-22 10:03:51 +0200 )edit

Just setup an new gmail account for this but still no luck, getting this:

LibreOffice could not connect to the outgoing mail server. Check your system's settings and the settings in LibreOffice. Check the server name, the port and the secure connections settings

<class 'smtplib.smtpserverdisconnected'="">: Connection unexpectedly closed, traceback follows File "C:\Program Files (x86)\LibreOffice 5\program\mailmerge.py", line 107, in connect self.server = smtplib.SMTP(server, port,timeout=

Jonathan MPS LTD gravatar imageJonathan MPS LTD ( 2017-09-22 13:16:22 +0200 )edit

I've just taken screenshots of my setting but I can't upload them here!!!!!!!!!!!

Jonathan MPS LTD gravatar imageJonathan MPS LTD ( 2017-09-22 13:20:43 +0200 )edit

Pasted in another error in original message as this comment box doesn't give enough characters!

Jonathan MPS LTD gravatar imageJonathan MPS LTD ( 2017-09-22 13:25:57 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2019-01-31 18:20:47 +0200

wb8nbs gravatar image

I think I've finally got reliable connection to Yahoo POP server (outbound.att.net, port 465). The usual error message when I did the test from Tools->Options->LibreOffice Writer->MailMerge Email was "starttls extension not supported by server". I made 2 changes to the python code in Linux at /usr/lib/libreoffice/program/mailmerge.py. I am on Ubuntu 16.04, Libre version is 5.1.6.2.

First made the change suggested in http://ask.libreoffice.org/en/questio...

from self.server = smtplib.SMTP(server, port,timeout=tout) to self.server = smtplib.SMTP_SSL(server, port,timeout=tout)

which helped sometimes but still connection usually did not work.

Second, I see Python docs http://docs.python.org/3/library/smtp... on SMTP_SSL, it says starttls is not necessary in an already established SSL connection. So I commented out the offending starttls lines. The code in mailmerge.py now looks like:

self.server = smtplib.SMTP_SSL(server, port,timeout=tout)

            #stderr not available for us under windows, but
            #set_debuglevel outputs there, and so throw
            #an exception under windows on debugging mode
            #with this enabled
            if dbg and os.name != 'nt':
                    self.server.set_debuglevel(1)

            connectiontype = xConnectionContext.getValueByName("ConnectionType")
            if dbg:
                    print("ConnectionType: " + connectiontype, file=dbgout)
            if connectiontype.upper() == 'SSL':
            #self.server.ehlo()
            #self.server.starttls()
                    self.server.ehlo()

This is around line 120. Connection test and mail merge from Libre Writer seems to work now.

These changes may be erased and have to be redone if Libre does an update. Hope this helps someone.

edit flag offensive delete link more
0

answered 2019-05-20 18:30:27 +0200

erpiu gravatar image

updated 2019-05-21 11:27:07 +0200

With the modifications proposed by wb8nbs the connection is always a secure one using SSL/TLS. To support both secure and non secure connections we need to call either smtplib.SMTP or smtplib.SMTP_SSL depending on the value of connectiontype.

I've modified the file mailmerge.py (version LO 6.0.7 on Ubuntu) accordingly. Lines 105 to 124 become :

    if dbg:
        print("Timeout: " + str(tout), file=dbgout)

    # Modifications by erpiu: choose SMTP or SMTP_SSL depending on connectiontype
    connectiontype = xConnectionContext.getValueByName("ConnectionType")
    if dbg:
        print("ConnectionType: " + connectiontype, file=dbgout)
    if connectiontype.upper() == 'SSL':
        self.server = smtplib.SMTP_SSL(server, port,timeout=tout)
        # Following calls are not necessary when using SMTP_SSL
        #self.server.ehlo()
        #self.server.starttls()
        #self.server.ehlo()
    else:
        self.server = smtplib.SMTP(server, port,timeout=tout)

    #stderr not available for us under windows, but
    #set_debuglevel outputs there, and so throw
    #an exception under windows on debugging mode
    #with this enabled
    # End of modifications by erpiu

    if dbg and os.name != 'nt':
        self.server.set_debuglevel(1)

    user = xAuthenticator.getUserName()

With those modifications we can establish either a secure connection "by port" (ie from the very beginning) with an SMTP server, typically using the port 465 and SSL/TLS, or a non secure connection, for instance on the port 25 or 587.

Notice that, as it is programmed, we cannot switch from a non secure connection to a secure one using STARTTLS, which is another method to establish a secure connection (this method is often unsuitably referred to as "TLS" instead of "STARTTLS").

I hope all this helps.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2017-09-22 00:18:49 +0200

Seen: 445 times

Last updated: May 21