Bug 105071 - MailMerge: when running e-mail using a macro NO messages get sent
Summary: MailMerge: when running e-mail using a macro NO messages get sent
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.0.0.alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.4.0 target:5.2.6 target:5.3.0.2
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Mail-Merge
  Show dependency treegraph
 
Reported: 2017-01-03 16:48 UTC by Alex Kempshall
Modified: 2017-03-02 11:35 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
This is the starting document the MailMerge (12.19 KB, application/vnd.oasis.opendocument.text)
2017-01-03 16:49 UTC, Alex Kempshall
Details
This is the database for the mailmerge (11.72 KB, application/vnd.oasis.opendocument.database)
2017-01-03 16:50 UTC, Alex Kempshall
Details
This is the bisect log for this bug (3.22 KB, text/x-log)
2017-01-03 16:53 UTC, Alex Kempshall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Kempshall 2017-01-03 16:48:04 UTC
In Writer when attempting to email messages using a macro NONE get sent. This occurs when trying to send emails through either smtp.gmail.com or a smtp server running on localhost. 

This problem started to occur with commit e3e2a4a2d18b567f0add7cfcdede7b0c4cffbece. I've attached a bisect log for inspection.

In testing running with a smtp server on localhost avoids upsetting your email provider. When testing on localhost I use  "python -m smtpd -n -c DebuggingServer localhost:587 2>&1 | tee /tmp/smtpd.log" running in background, I've only ever managed running this server as root.


Steps to reproduce the problem.

1.
Download the files CompanySeedStarted1.odt and CompanySeedTestData1.odb from this bug report. The database CompanySeedTestData1.odb contains 63 entries all with dummy email addresses.

2.
Start LibreOffice writer with the document CompanySeedStarted1.odt downloaded in step 1. Note: this file contains a macro so be mindful that some security steps might need to be taken.

3.
Tools -> Mail Merge Wizard

4.
The "Select starting document" dialog box should appear. The left pane should contain 5 steps. In the right pane select the "Use Current Document" Radio Button. Then press the "Next >>" Button.

5.
The "Select document type" dialog box should appear. Select the "E-mail message" Radio Button. Then press the "Next" Button.

6.
The "Insert address block" dialog box should appear. Press the "Select Different Address List" Button.

7.
The "Select Address List" dialog box should appear. Press the "Add" Button.

8.
The "Open - LibreOffice" dialog should appear. Navigate to directory containing CompanySeedTestData1.odb downloaded in step 1. Once the database has been selected press the "Open" Button.

9.
The "Select Address List" dialog box should re-appear with the database CompanySeedTestData1 and the table tblCompanySeedTestData1 added to the list of available databases. If not already selected - select this database. Press the "OK" Button.

10.
Control should be returned to the "Mail Merge Wizard" dialog. Press the "Finish" Button.

11.
If not already done so. Establish the Mail Merge E-mail settings by navigating from the menu Tools -> Options -> LibreOffice Writer -> Mail Merge E-Mail

11.1
The  "Options LibreOffice Writer Mail Merge E-Mail" dialog should appear. Enter the senders name you want to be called by, the senders email address, the server name, the port number. If not already checked left click the "Use secure connection (SSL) check box. Push the "Server Authentification" Button.

11.2
The "Server Authentification" dialog should appear. Enter the senders email address and the senders password for the smtp server. Push the "OK" button.

11.3
Control will be passed back to the "Options LibreOffice Writer Mail Merge E-Mail" dialog. Push the OK Button. Control will return to the open document.

12.
Run the MailMerge macro by navigating from the menu Tools -> Macros - Run Macro.

13.
The "Macro Selector" dialog should appear.

14.
In the left hand "Library" pane navigate to the macro CompanyStarted1.odt -> Standard -> CompanyStarted1

15.
In the right hand "Macro Name" pane select the macro "Email_Test_0001". Press the "Run" button".

16.
Control should be passed back to the document. Progress will be indicated by the progress bar in the status area. Should process 63 of 63 messages. A "Done" message box should appear.

17.
Though the Mail Merge process indicates that 63 messages have been processed NONE appear on the server configured in the "Mail Merge E-mail settings" dialog. 

18.
When running LibreOffice 5.1.5.2 all 63 messages appear when the "Mail Merge E-mail settings" are configured for localhost. Because of tdf#103919 only a few messages appeared when the "Mail Merge E-mail settings" was configured for smtp.gmail.com


Alex
Comment 1 Alex Kempshall 2017-01-03 16:49:30 UTC
Created attachment 130116 [details]
This is the starting document the MailMerge

See instructions in initial comment
Comment 2 Alex Kempshall 2017-01-03 16:50:42 UTC
Created attachment 130117 [details]
This is the database for the mailmerge

This is the database used in the instructions of the initial comment.
Comment 3 Alex Kempshall 2017-01-03 16:53:39 UTC
Created attachment 130118 [details]
This is the bisect log for this bug

e3e2a4a2d18b567f0add7cfcdede7b0c4cffbece is the first bad commit
commit e3e2a4a2d18b567f0add7cfcdede7b0c4cffbece
Author: Jan-Marek Glogowski <glogow@fbihome.de>
Date:   Wed Jan 27 11:42:45 2016 +0100

    MM: move mail creation into a local function
    
    And also use C++11 range-based for loop loops.
    
    Change-Id: I7bafc419a21cdd6bb7aaed7d67b640409d308f79

:040000 040000 4ee93c2daaa57422a9c19a0152f0f2de7dc2f9e1 75cf70819820afba2d72cb5490d99c43fe49e85c M      sw
Comment 4 Buovjaga 2017-01-04 11:53:32 UTC
Adding jmux to CC
Comment 5 Xisco Faulí 2017-01-04 17:15:45 UTC
Moving it to NEW as the problem commit has been identified.
Comment 6 Alex Kempshall 2017-01-10 09:44:17 UTC
With this change I'm getting the expected results.

diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 3ae101a..99aeec0 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -995,7 +995,7 @@ uno::Reference< mail::XMailMessage > lcl_CreateMailFromDoc(
         SfxMedium aMedium( sFileURL, StreamMode::READ );
         SvStream* pInStream = aMedium.GetInStream();
         assert( pInStream && "no output file created?" );
-        if( pInStream )
+        if( !pInStream )
             return xMessage;
 
         pInStream->SetStreamCharSet( sMailEncoding );
Comment 7 Alex Kempshall 2017-01-10 09:49:22 UTC
With the above change and using a local smtp server I get the expected results.

If I use a remote server like smtp.gmail.com I only get the fist few records through, in one test I got 9 messages out of 62 on another 16 out of 62 .

This would suggest another latency bug in the code similar to that identified in tdf103919.
Comment 8 Jan-Marek Glogowski 2017-01-11 18:09:48 UTC
Want to send a patch to Gerrit? I can push and backport it ;-)
Comment 9 Commit Notification 2017-01-12 17:27:47 UTC
Alex McMurchy1917 committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=03ec9c397c676faff51041d992f6d715c475ff13

tdf#105071 MM no emails sent when using doc as mail body

It will be available in 5.4.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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2017-01-13 11:52:16 UTC
Alex McMurchy1917 committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9ec13271b435dc5b2e1753507e1e470624bb93ae&h=libreoffice-5-2

tdf#105071 MM no emails sent when using doc as mail body

It will be available in 5.2.6.

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2017-01-13 11:52:23 UTC
Alex McMurchy1917 committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4c8be6327f6d71d426bbf9887fd7d8a24ffd06a3&h=libreoffice-5-3

tdf#105071 MM no emails sent when using doc as mail body

It will be available in 5.3.0.2.

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Xisco Faulí 2017-03-01 11:02:12 UTC
Hello,
Is this bug fixed?
If so, could you please close it as RESOLVED FIXED?
Comment 13 Alex Kempshall 2017-03-02 11:35:14 UTC
Pulled branch 5.3.1 from git and all messages sent via my gmail account successfully and received at their respective destinations.

Pulled master from git and all messages sent via my gmail account successfully and received at their respective destinations.

Will close as RESOLVED FIXED.