Bug 63388 - MAILMERGE: LibreOffice freezes when clicking Test Settings button
Summary: MAILMERGE: LibreOffice freezes when clicking Test Settings button
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: All All
: high normal
Assignee: Not Assigned
Whiteboard: BSA target:6.1.0
: 48538 58703 64098 75481 99363 109019 (view as bug list)
Depends on:
Blocks: Mail-Merge
  Show dependency treegraph
Reported: 2013-04-10 15:39 UTC by Dan Lewis
Modified: 2023-04-12 06:10 UTC (History)
19 users (show)

See Also:
Crash report or crash signature:

mailmerge.py patch to work with smtp port 465 (987 bytes, patch)
2017-07-17 05:17 UTC, Jurassic Pork

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Lewis 2013-04-10 15:39:50 UTC
Problem description: 
I enter my email information including what is required to authenticate me copying this information directly from my email client, Thunderbird. But when I test the settings, LibreOffice freezes. I use Gmail. OS: Ubuntu 12.04 LST 64 bit.
Steps to reproduce:
1. Tools > Options > LibreOffice Writer > Mail Merge Email
2. Copy the User information and Outgoing Server Settings
3. Check Use Secure connection (SSL)
4. Click Server Authentication button.
5. Check the box at the top.
6. Select this option button: The outgoing mail server (SMTP) requires separate authentication.
7. Copy server information from Thunderbird, and click OK.
8. Click the Test Settings button. LibreOffice freezes after approximately 5-10 seconds.

Current behavior:
I get the same results using LibreOffice,, and I have verified that the password entered is the one required to access Gmail on the Google website.I use IMAP with Google if that matters.

Expected behavior:
When the Test Settings button is clicked, I should get a message stating the test was successful or at least a hint of what went wrong.

Operating System: Ubuntu
Version: rc
Comment 1 Alex Thurgood 2013-04-10 16:26:23 UTC
Confirming also on LO, 3.6.5 on OSX 10.8.3

This used to work in 3.3.x (although I haven't tested recently).

It also might be a DUP of a previously entered report (will have to look).

Comment 2 Alex Thurgood 2013-04-10 16:42:20 UTC Comment hidden (obsolete)
Comment 3 Alex Thurgood 2013-04-10 17:01:37 UTC Comment hidden (obsolete)
Comment 4 Alex Thurgood 2013-04-10 17:37:38 UTC Comment hidden (obsolete)
Comment 5 Alex Thurgood 2013-06-14 04:38:39 UTC

For gmail, these are the settings that worked for me :

SSL option ticked
Port 25

Under "Server Authentication"
Tick "Outgoing mail server (SMTP) requires authentication"
Select "The outgoing mail server requires separate authentication"
User name : enter full Gmail address here, including the @gmail.com
Password : fill in with password

No need to configure the Incoming Mail Server options

Comment 6 Andrea Tessadri 2014-09-13 14:54:57 UTC
I couldn't figure out the way to have mailmerge working with my Gmail SMTP but when I did the debug of the mailmerge.py script I've discovered that a SSL connection isn't handled properly.
At the line where the server object is created I found:

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

but in case of SSL connection the correct statement should be:

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

So, I did this simple change and my Gmail SMTP (smtp.gmail.com) works perfectly on port 465.
I didn't even checked the "Use SSL" checkbox in the mailmerge configuration windows.

I think a good patch should make a choice between smtplib.SMTP and smtplib.SMTP_SSL according to the "Use SSL" checkbox.


Comment 7 mrmister001 2014-10-23 11:39:46 UTC
LibreOffice Writer crash miserably when I try to send documents via email
I have my settings perfectly configured, port, ssl, smtp server, etc. and this freeze completely.
I did the changes that Andrea suggested but in my case are not working...
Comment 8 Julien Nabet 2015-02-21 15:05:45 UTC
*** Bug 75481 has been marked as a duplicate of this bug. ***
Comment 9 Julien Nabet 2015-02-21 15:06:08 UTC
*** Bug 64098 has been marked as a duplicate of this bug. ***
Comment 10 Julien Nabet 2015-02-21 15:08:14 UTC
Thank you Andrea/FS for your ideas (see https://bugs.documentfoundation.org/show_bug.cgi?id=64098#c15 + https://bugs.documentfoundation.org/show_bug.cgi?id=63388#c6),
I'll submit a patch with these.
Comment 11 Julien Nabet 2015-02-21 15:10:20 UTC
*** Bug 58703 has been marked as a duplicate of this bug. ***
Comment 12 Julien Nabet 2015-02-23 18:03:04 UTC
It seems the patch is wrong (see https://gerrit.libreoffice.org/#/c/14572/), so abandonned it.
Certainly someone will know how to fix this.
Comment 13 Bernt Andreas Drange 2015-06-02 20:58:06 UTC
This bug is also reported at ask.libreoffice.org: 

Comment 14 Julien Nabet 2016-12-30 15:32:23 UTC
*** Bug 99363 has been marked as a duplicate of this bug. ***
Comment 15 Julien Nabet 2016-12-30 15:35:41 UTC
Jan-Marek: a solution has been proposed by prrvchr in tdf#99363.
Comment 16 prrvchr 2017-02-05 11:50:11 UTC
Work fine for me, but need some Google Mail Account setting requirement:

Load: https://myaccount.google.com/security?utm_source=OGB#connectedapps

You must enable less secured application. Needed but apparently the connection is under SSL...
Comment 17 prrvchr 2017-04-04 22:16:14 UTC
I make an extension gMailOOo:


Who implements ssl and tls as well as OAuth2.
Uno api uno seems obsolete and requires an upgrade.
Comment 18 prrvchr 2017-04-06 11:32:47 UTC
Interface who need modification:


getSupportedConnectionTypes: return (Unsecure, Ssl, Tls)

getConnectionType: after connection return Ssl (effective connection type)

getSupportedAuthenticationTypes: return (None, Login, Component)

getAuthenticationType: after connection return effective authentication type

Connect(xConnectionContext, xAuthenticator)





PopbeforeSmtp and ImapbeforeSmtp are old technology that was used when smtp did not handle authentication.
It may no longer be necessary to keep it.
Comment 19 Martyn Hare 2017-04-30 10:54:25 UTC
This bug still exists in latest LibreOffice at time of writing (5.3.2)

Platform: Windows x64
Version: 5.3.2

SMTP: smtp.office365.com
Port: 25
SSL: Both TLS/SSL and StartTLS cause the crash when testing.

Steps to reproduce: 

Do as original poster (Dan Lewis) did.  Nothing has changed here.


This bug is now 5 years old and affects Office 365 SMTP as well as Google Apps.  These are two of the biggest business e-mail providers in terms of client base.  Small business can't use LibreOffice until this is fixed.

I appreciate LibreOffice devs have a lack of resources, but this is basic functionality that prevents me and many of the clients I support from dumping Microsoft Office and by extension, Windows.
Comment 20 prrvchr 2017-05-30 22:08:10 UTC
at Martyn Hare:

can you try to install this extention:


It work now on Windows...
Comment 21 Jurassic Pork 2017-06-16 04:44:09 UTC
there is a problem when you use SMTP with the port 465 
you must use a smtplib.SMTP_SSL with this port.
Proposed code in mailmerge.py : 
		if port == 465:
			self.server = smtplib.SMTP_SSL(server, port,timeout=tout)
			self.server = smtplib.SMTP(server, port,timeout=tout)

		if dbg and os.name != 'nt':

		connectiontype = xConnectionContext.getValueByName("ConnectionType")
		if dbg:
			print("ConnectionType: " + connectiontype, file=dbgout)
		if connectiontype.upper() == 'SSL' and port != 465:
Comment 22 Julien Nabet 2017-06-16 05:15:40 UTC
Jurassik: if you want to contribute and submit your patch, you can give a look to https://wiki.documentfoundation.org/Development/GetInvolved

For the moment, there's no patch pushed on sources so this bug is not fixed.
Comment 23 prrvchr 2017-06-17 12:51:14 UTC Comment hidden (obsolete)
Comment 24 prrvchr 2017-06-17 13:05:34 UTC Comment hidden (obsolete)
Comment 25 Julien Nabet 2017-06-17 13:33:30 UTC Comment hidden (obsolete)
Comment 26 Jurassic Pork 2017-06-18 07:05:36 UTC
(In reply to prrvchr from comment #24)
> A three-state control is required for the choice of connection security
> (none, Ssl, Tls)
> Same for authentication (without, login, oauth2)
> Take look at:
> https://forum.openoffice.org/en/forum/viewtopic.php?f=47&t=89140

with my mailmerge.py code : 
for use of SMTP port 25 : 
don't check ssl checkbox
for use of SMTP port 465 :
check ssl checkbox
for use of SMTP port 587 :
check ssl checkbox

Julien Nabet english is not my natural language but if i have understand your link, you must build or download all the source of libreoffice to make a patch. Sorry but it is too complicated for me to do a patch. Only a few lines change in mailmerge.py
Comment 27 Julien Nabet 2017-06-18 07:12:50 UTC Comment hidden (obsolete)
Comment 28 Jurassic Pork 2017-07-05 00:00:12 UTC
if you want to try my file mailmerge.py you can find here : 

tried with LibreOffice
Comment 29 Arnaud Versini 2017-07-16 09:51:12 UTC Comment hidden (obsolete)
Comment 30 Arnaud Versini 2017-07-16 10:22:15 UTC
*** Bug 109019 has been marked as a duplicate of this bug. ***
Comment 31 Jurassic Pork 2017-07-17 05:17:06 UTC
Created attachment 134677 [details]
mailmerge.py patch to work with smtp port 465

would work since version 5.0 of libreOffice
Comment 32 Tangine Melroux 2017-07-28 20:01:11 UTC
(In reply to Jurassic Pork from comment #21)
> hello,
> there is a problem when you use SMTP with the port 465 
> you must use a smtplib.SMTP_SSL with this port.
> Proposed code in mailmerge.py : 
> 		if port == 465:
> 			self.server = smtplib.SMTP_SSL(server, port,timeout=tout)
> 		else:
> 			self.server = smtplib.SMTP(server, port,timeout=tout)
> 		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' and port != 465:
> 			self.server.ehlo()
> 			self.server.starttls()
> 			self.server.ehlo()

I made your changes to today's version of LO on Win7 x86 (still v5.3.4), but I just get

<class 'AttributeError'>: 'module' object has no attribute 'SMTP_SSL', traceback follows
  File "C:\Program Files\LibreOffice 5\program\mailmerge.py", line 110, in connect
    self.server = smtplib.SMTP_SSL(server, port,timeout=tout)

when I try to use SSL to port 465.

It appears that there is no guarantee that the Python included with LO has SSL support enabled.

This is reinforced by the following error if I try port 587 with SSL

<class 'RuntimeError'>: No SSL support included in this Python, traceback follows
  File "C:\Program Files\LibreOffice 5\program\mailmerge.py", line 128, in connect
  File "C:\Program Files\LibreOffice 5\program\python-core-3.3.0\lib\smtplib.py", line 663, in starttls
    raise RuntimeError("No SSL support included in this Python")

So, any clues as to how I get a version of LO with SSL actually working ? Is it a lottery ? It obviously worked for your version - what platform were you using it on ?
Comment 33 Tangine Melroux 2017-07-28 21:02:26 UTC Comment hidden (obsolete)
Comment 34 Tangine Melroux 2017-07-29 14:26:51 UTC
(In reply to Tangine Melroux from comment #33)
> FIX:
> LO Version:
> Build ID: f82d347ccc0be322489bf7da61d7e4ad13fe2ff3
> Win 7 x86
> C:\Program Files\LibreOffice 5\program\python-core-3.3.0\lib\_ssl.pyd
> is useless
> download Python 3.3.5 MSI from python.org and install
> copy
> C:\Program Files\Python33\DLLs\_ssl.pyd
> from there to overwrite broken LO.
> Now two blue ticks for tests at ports 465 and 587 with Jurassik's patch
> 2013 ???


LO 'Send E-mail Messages' button in new toolbar gets to the last step, dialog box flashes up momentarily (too fast to read) - no errors indicated, but no e-mail messages actually sent.

Trying to find where LO stores error logs on Windows reveals that it doesn't - so no further progress possible - all Googling shows either Mac/Linux solutions to log location or nightmare nonsense like

"C:\OpenOffice\program\soffice.exe" -Xdebug -env:RTL_LOGFILE=c:\\OpenOffice -Xrunjdwp:transport=dt_socket,server=y,address=22222 -invisible -"accept=socket,host=0,port=22222;urp;debug=true"
works partial.

It creates a file
But it remains empty.

Comment 35 ubundom 2017-08-14 13:00:07 UTC
Build ID: 50d9bf2b0a79cdb85a3814b592608037a682059d
OS: Win7 v6.1 Build 7601 SP1

server: smtp.fastmail.com SMTP port: 465

Still not working:

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=tout)
  File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.0\lib\smtplib.py", line 241, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.0\lib\smtplib.py", line 322, in connect
    (code, msg) = self.getreply()
  File "C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.0\lib\smtplib.py", line 375, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
Comment 36 Mamoth 2017-08-24 09:35:58 UTC

I had a similar problem with LO on Linux Mint 17.3 and LO 5.2 under Windows 7 (although after about ~ 10 mn, the window would unfreeze and I would get a proper error message for the connexion testing).

It was solved once I changed the port from 465 to 587. 
The problem was that 'SSL connexion' may means SSL/TLS (which was port 465 with my SMTP server) or STARTTLS (which was port 587 with the SMTP server).
Comment 37 royerjy 2018-01-21 10:26:59 UTC
Emailing and Libo hang when clicking on button "Sélectionner une liste d'adresses".

It would be better to remove this function from menu.

Linux Mint 18.3
Comment 38 Commit Notification 2018-01-30 04:23:29 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":


tdf#63388: use SMTP_SSL for port 465

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:

Affected users are encouraged to test the fix and report feedback.
Comment 39 Justin L 2018-01-30 06:35:56 UTC
Thanks to Jurassic Pork (comment 21) and prrychr (tdf#99363) for the 2016 patch. 

A few related changes have resulted in this situation for LO 6.1
-secure SMTP is now default with port 587 (StartTLS).
-POP3/IMAP also default to secure ports.
-Port 465 uses smtp_ssl (regardless of the setting labeled SSL, but which actually implements StartTLS in the case of SMTP). SO, PORT 465 IS THE ONLY PORT THAT LIBREOFFICE CAN USE FOR SSL SMTP.

So, I think this will take care of most of the concerns mentioned in this report. I'm not going to mark this one as resolved since there are so many different angles in this bug.

1) The term "SSL" is correct for POP3/IMAP settings in the authentication portion (right?), but for SMTP, "SSL" is different (and incompatible) with "StartTLS". Consider the three-way logic of comment 18.

2) test smtp_ssl works on the shipping version of python (comment 32, 33, 34). It works for me in Ubuntu 16.04 / 18.04.

3) LibreOffice freezes when clicking Test Settings button. That is the title of this bug, although there was very little in the discussion about this specific aspect.

If, after testing 6.1, there are still concerns about any of these topics, I recommend opening a new bug about that one particular topic, and linking it back to this report.
Comment 40 Justin L 2018-02-12 07:10:43 UTC
*** Bug 48538 has been marked as a duplicate of this bug. ***
Comment 41 prrvchr 2019-07-18 21:08:35 UTC
Hi all,

I come back and I are ready now to modify Uno Api (mailmerge.py) to be compatible with new SMTP servers technologie:
- The chosen port does not determine the security but only port... 
- For security available choices are: None, TLS or SSL
- For Authentication available choices: None, Login, OAuth2
I know now how to create idl file, and compile them to rdb file...

I could try to do it now, but with some help to define the new method of idl and want that this correction is produced as an extension compatible with OpenOffice ...

I'm waiting for a reply, thank you.
Comment 42 prrvchr 2019-07-20 07:11:59 UTC
If you want to get closer to the quality of an email client's configuration like Thunderbird, we need:
- use Mozilla ISPDB
- create a Configuration Wizard based on ISPDB.
- integrate in SMTP services an InteractionHandler calling the Configuration Wizard if a parameter is missing
Comment 43 Robert 2020-03-11 05:47:27 UTC Comment hidden (spam)
Comment 44 Julien Nabet 2020-03-11 06:05:54 UTC Comment hidden (obsolete)
Comment 45 Buovjaga 2022-04-07 12:07:35 UTC
Does anyone in this report experience any problem with a fresh master build? There were recent fixes to mail merge code.
Comment 46 Stéphane Guillou (stragu) 2023-04-12 06:10:42 UTC
There hasn't been a duplicate or "me too" comment since Justin's 2018 commit, and no reply to Buovjaga's question from a year ago, so closing as fixed by Justin's commit.

If issues remain, please see if it has already been reported: https://bugs.documentfoundation.org/showdependencytree.cgi?id=102998&hide_resolved=1
If not, please open a new report.

prrvchr, if you want to improve mail merge with larger-scale changes, I think it would be good to write to the dev mailing list to reach more people and get other opinions: https://lists.freedesktop.org/mailman/listinfo/libreoffice
Much appreciated!