Closed Bug 1741596 Opened 2 months ago Closed 2 months ago

Allow External App to Send Email - Version 91.3.0 (64-bit)

Categories

(Thunderbird :: OS Integration, defect)

Thunderbird 91
defect

Tracking

(thunderbird_esr91 fixed, thunderbird95 fixed)

RESOLVED FIXED
96 Branch
Tracking Status
thunderbird_esr91 --- fixed
thunderbird95 --- fixed

People

(Reporter: simon, Assigned: rnons)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0

Steps to reproduce:

I allow external apps to send email using MAPI.
This stopped working after the update on the 14-11-21 to Thunderbird 91.3.1 (64-bit).
Rolling back to version 91.3.0 (64-bit) has allowed me to send the email.

Actual results:

I set Thunderbird offline. The external app generated the PDF attachments for the emails, and went through the process of creating the emails. But the emails never appeared in the Thunderbird outbox.

Expected results:

The external app generated emails should appear in the Thunderbird outbox.

simon, do you use the sendlater add-on? Or are you just running thunderbird offline? Also, exactly what application are you sending from?

This might a regression caused by Bug 1735601 - Mapi attachments disappear from moz-mapi folder before email sent, causing "Sending of the message failed." after update to 91.2.0

Flags: needinfo?(simon)
Flags: needinfo?(remotenonsense)
Regressed by: 1735601

FWIW, Rob found an oldie Bug 298126 - In Offline mode, message sent via MAPISendMail will not save the unsent mail in Outbox (Unsent Messages)

(In reply to Wayne Mery (:wsmwk) from comment #2)

simon, do you use the sendlater add-on? Or are you just running thunderbird offline? Also, exactly what application are you sending from?

This might a regression caused by Bug 1735601 - Mapi attachments disappear from moz-mapi folder before email sent, causing "Sending of the message failed." after update to 91.2.0

Hi Wayne.
No I do not use the sendlater add-on. As the external app sends batches of emails, I go offline so they all collect up in the outbox and then go online to send them.
The application is Pegasus Opera3 - www.pegasus.co.uk - it is a business program for Purchase Ordering, Payroll, Sales, etc.
Thank you.

Flags: needinfo?(simon)

So what are the steps for someone without pegasus to reproduce this?
Does this way of handing over a complete message to Thunderbird end up in a Thunderbird command line?
Is the complete message first stored somewhere and then goes to TB via Windows MAPI handlers? What's the MAPI call/procedure?

Flags: needinfo?(simon)

Hi Thomas
I've had a look through the Pegasus user manual (I don't have access to their code/specs) and it states:
"MAPI-compliant e-mail software like Microsoft Outlook installed."
So, I'm guessing that any MAPI software, or MAPI test script, should give the same results?!? Dirk had a test program in this report that may be helpful: https://bugzilla.mozilla.org/show_bug.cgi?id=298126
I'm happy to help with testing if needed.
Thank you.

Flags: needinfo?(simon)

I don't know about Pegasus, can you try with a local file first

  1. go to the Settings page, find Config Editor, set mailnews.send.loglevel to All
  2. set TB to offline (and open DevTools, clear all output in the Console tab)
  3. right click a local file
  4. select 'Send to > Mail recipient'
  5. fill the To address
  6. click the 'Send Later' button

Does the mail appear in your Outbox? If not, please paste the logs here. If yes, clear the Console tab again, and try sending from Pegasus, and get the logs.

Flags: needinfo?(remotenonsense)

Hi Ping
In the first test the email did appear in the outbox.

In the second test the 2 emails did not appear in the outbox.
The PDF email attachments did appear and very rapidly disappear in this folder: C:\Users\USERNAME\AppData\Local\Temp\moz_mapi

Log:
---------- Test 2 --------------
mailnews.send: Creating message file MessageSend.jsm:116:25
mailnews.send: Fetching file:///C:/Users/USERNAME/AppData/Local/Temp/moz_mapi/Carters%20Limited18112021.PDF MimePart.jsm:255:25
mailnews.send: Failed to fetch attachment; name=Carters Limited18112021.PDF, url=file:///C:/Users/USERNAME/AppData/Local/Temp/moz_mapi/Carters%20Limited18112021.PDF, error=asyncFetch failed with status=2152857618 MimePart.jsm:159:29
mailnews.send:
Exception { name: "", message: "Failed to fetch attachment", result: 2153066778, filename: "resource:///modules/MimePart.jsm", lineNumber: 162, columnNumber: 0, data: XPCWrappedNative_NoHelper, stack: "getEncodedBodyString@resource:///modules/MimePart.jsm:162:26\n", location: XPCWrappedNative_NoHelper }
MessageSend.jsm:122:27
mailnews.send: Sending failed; There was an error attaching Carters Limited18112021.PDF. Please check that you have access to the file., exitCode=2153066778, originalMsgURI= MessageSend.jsm:321:27
mailnews.send: Clean up temporary files MessageSend.jsm:1000:25
mailnews.send: notifyListenerOnStopSending; status=2153066778 MessageSend.jsm:486:25
NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIWindowWatcher.openWindow] PromptParent.jsm:161
mailnews.send: Creating message file MessageSend.jsm:116:25
mailnews.send: Fetching file:///C:/Users/USERNAME/AppData/Local/Temp/moz_mapi/Richardson%20Auto%20Services%20Ltd.PDF MimePart.jsm:255:25
mailnews.send: Failed to fetch attachment; name=Richardson Auto Services Ltd.PDF, url=file:///C:/Users/USERNAME/AppData/Local/Temp/moz_mapi/Richardson%20Auto%20Services%20Ltd.PDF, error=asyncFetch failed with status=2152857618 MimePart.jsm:159:29
mailnews.send:
Exception { name: "", message: "Failed to fetch attachment", result: 2153066778, filename: "resource:///modules/MimePart.jsm", lineNumber: 162, columnNumber: 0, data: XPCWrappedNative_NoHelper, stack: "getEncodedBodyString@resource:///modules/MimePart.jsm:162:26\n", location: XPCWrappedNative_NoHelper }
MessageSend.jsm:122:27
mailnews.send: Sending failed; There was an error attaching Richardson Auto Services Ltd.PDF. Please check that you have access to the file., exitCode=2153066778, originalMsgURI= MessageSend.jsm:321:27
mailnews.send: Clean up temporary files MessageSend.jsm:1000:25
mailnews.send: notifyListenerOnStopSending; status=2153066778 MessageSend.jsm:486:25
NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIWindowWatcher.openWindow] PromptParent.jsm:161
---------- Test 2 End ----------

Thank you for your help.

To prevent ~nsMsgComposed being called before sending finishes.

Assignee: nobody → remotenonsense
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Hi
I downloaded the artifact build, extracted it and copied it to Program Files (x86). Just to confirm it is Daily Version 96.0a1 (2021-11-19) (64-bit).
I repeated your tests from comment 7. Both tests now fail.

Test 1. When I right click a file select 'Send to > Mail recipient' I get a MS Office Outlook error:
"Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client."
The console didn't show an error for 5 to 10 seconds, and then this appeared:

Content Security Policy: Ignoring “'unsafe-inline'” within script-src: ‘strict-dynamic’ specified
Content Security Policy: Ignoring “https:” within script-src: ‘strict-dynamic’ specified
Content Security Policy: Ignoring “http:” within script-src: ‘strict-dynamic’ specified
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://play.google.com/log?format=json&hasfast=true&authuser=0. (Reason: CORS request did not succeed). Status code: (null). 2

Test 2. When I try and send the emails from Pegasus I get the error: "Unable to send email at present"
Again the console didn't show an error for 5 to 10 seconds, and then this appeared:

Content Security Policy: Ignoring “'unsafe-inline'” within script-src: ‘strict-dynamic’ specified
Content Security Policy: Ignoring “https:” within script-src: ‘strict-dynamic’ specified
Content Security Policy: Ignoring “http:” within script-src: ‘strict-dynamic’ specified
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://signaler-pa.clients6.google.com/punctual/v1/chooseServer?key=AIzaSyCkokF7ksaXeZWuLoDCuE1JGr7Ktzg2mXM. (Reason: CORS request did not succeed). Status code: (null). 2

Just to confirm that Windows does show TB as the default mail client. I also went in to TB General Settings and under System Integration used the check now button to make sure that TB was the default mail client - and then repeated the tests, and got the same results.
Thank you.

Flags: needinfo?(simon)

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/b3a061695184
Wait for SendMsg in msgMapiHook.cpp to prevent ~nsMsgComposed being called before sending finishes. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED

I tested just now and got the same error. Seems daily build doesn't work with MAPI, I guess the installer handles the MAPI registration. Please wait a few days for this to get into beta, and then esr91.

Target Milestone: --- → 96 Branch

Comment on attachment 9251499 [details]
Bug 1741596 - Wait for SendMsg in msgMapiHook.cpp. r=mkmelin

[Approval Request Comment]
Regression caused by (bug #): bug 1735601
User impact if declined: nsMapiHook::BlindSendMail doesn't work for attachments, BlindSendMail means compose window is not brought up when sending
Testing completed (on c-c, etc.): didn't find a way to test on daily build (see comment 11, comment 13)
Risk to taking this patch (and alternatives if risky): only affects nsMapiHook::BlindSendMail

Attachment #9251499 - Flags: approval-comm-esr91?
Attachment #9251499 - Flags: approval-comm-beta?

Comment on attachment 9251499 [details]
Bug 1741596 - Wait for SendMsg in msgMapiHook.cpp. r=mkmelin

[Triage Comment]
Approved for beta

Attachment #9251499 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9251499 [details]
Bug 1741596 - Wait for SendMsg in msgMapiHook.cpp. r=mkmelin

[Triage Comment]
Approved for ers91

Attachment #9251499 - Flags: approval-comm-esr91? → approval-comm-esr91+

Comment on attachment 9251499 [details]
Bug 1741596 - Wait for SendMsg in msgMapiHook.cpp. r=mkmelin

I have to backout this patch from comm-esr91 as it caused Windows build failures.

https://treeherder.mozilla.org/jobs?repo=comm-esr91&selectedTaskRun=P8mC5HVpSju2QxZpXT-TZw.0

Ping, can you take a look? 91.4.0 doesn't ship until next week, this fix can still be included.

Flags: needinfo?(remotenonsense)
Attachment #9251499 - Flags: approval-comm-esr91+
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

(In reply to Ping Chen (:rnons) from comment #14)

Testing completed (on c-c, etc.): didn't find a way to test on daily build (see comment 11, comment 13)

You can build an installer for Daily with mach package. Then you can install Daily and test MAPI things. MAPI is usually directed to the last installed instance of TB. BTW, why did you remove the offline check?

Looks like the snippet now needs to be

  RefPtr<DomPromiseListener> listener = new DomPromiseListener(
      promise,
      [&](JSContext*, JS::Handle<JS::Value>) { sendMsgFinished = true; },
      [&](nsresult) { sendMsgFinished = true; });
  mozilla::SpinEventLoopUntil([=]() { return sendMsgFinished; });

https://searchfox.org/mozilla-central/diff/1662a8faa67cbc597e40ffce754a54cf10c5b712/toolkit/components/extensions/webidl-api/ExtensionEventListener.cpp#61
https://searchfox.org/mozilla-esr91/rev/b03b34bae68d74650ad719958462a56900f3298a/xpcom/threads/SpinEventLoopUntil.h#81

  • OnStopSending is not called when saving to Outbox
  • test_mapisendmail.js still fails on TreeHerder, but useful for local testing

Thanks, I will make a patch for esr91 tomorrow.

Flags: needinfo?(remotenonsense)

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/9502064d884f
Fix nsMapiHook::BlindSendMail for offline mode and add tests. r=mkmelin

Status: REOPENED → RESOLVED
Closed: 2 months ago2 months ago
Resolution: --- → FIXED
Attached patch 1741596-esr91.patch (obsolete) — Splinter Review

[Approval Request Comment]
Merged the two patches and fixed for esr91. Since this only affects nsMapiHook::BlindSendMail, I suggest we skip beta this time.

Attachment #9253138 - Flags: approval-comm-esr91?

Is promise->AppendNativeHandler(listener); still required? Here it was added after removing the promise parameter:
https://searchfox.org/mozilla-central/diff/1662a8faa67cbc597e40ffce754a54cf10c5b712/toolkit/components/extensions/webidl-api/ExtensionEventListener.cpp#61 (already quoted in comment #22). Also the use of [&] and [=] is inconsistent, have you looked what that syntax does?

Flags: needinfo?(remotenonsense)

Thanks, you're right, AppendNativeHandler is not needed for 91. I tend to use = (use by value) when & (use by ref) is not needed.

[Approval Request Comment]
Merged the two patches and fixed for esr91. Since this only affects nsMapiHook::BlindSendMail, I suggest we skip beta this time.

Attachment #9253138 - Attachment is obsolete: true
Attachment #9253138 - Flags: approval-comm-esr91?
Flags: needinfo?(remotenonsense)
Attachment #9253183 - Flags: approval-comm-esr91?

Comment on attachment 9253183 [details] [diff] [review]
1741596-esr91.patch

This seems unneeded. I will make a new patch for bug 1741805 later today, which will also fix this bug.

Attachment #9253183 - Flags: approval-comm-esr91?

Upgraded to 91.4.0 and can confirm that this issue has been resolved.
Thank you :-)

You need to log in before you can comment on or make changes to this bug.