Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mailto links - support using template if body argument is not empty #33

Open
RealRaven2000 opened this issue Jan 14, 2020 · 8 comments
Open
Assignees

Comments

@RealRaven2000
Copy link
Owner

@RealRaven2000 RealRaven2000 commented Jan 14, 2020

At the moment, no template is used when a mailto link is followed with anything as a body argument. It should be possible to

  • throw away the transmitted text from the mailto link if it only contains whitespace
  • inject the body text into the template with a new variable, e.g. %mailto(body)%
@RealRaven2000

This comment has been minimized.

Copy link
Owner Author

@RealRaven2000 RealRaven2000 commented Jan 14, 2020

Here is a first test version - 2.8 prerelease 106

smartTemplate-fx-2.8pre106.zip

(to install, unzip and drag file into Thunderbird Add-ons manager)

Here is a quick test template - add to "Write" template for main account's default identity.

<p>%dateshort%, week %cwIso(0)%, %tz_name% test</p>
  <p>Dear %cursor%,</p>
  <p>%mailto(body)%</p>
  <p>yours sincerely, <br>
     &nbsp;&nbsp;%identity(name)%</p>
<hr>

%sig(2)%

note: if template is used normally (not through mailto link but by clicking on the "Create a new message" button), then the variable will be removed silently.

If the variable is left out and body is only white space (no HTML tags) then the normal template should also be loaded. Try with this Test site.

@micha917

This comment has been minimized.

Copy link

@micha917 micha917 commented Jan 15, 2020

Just some observations on this issue. [And I apologize for any issue with my example mail postings. It seems that the preview function and I are not yet friends :-( ]
I used Smarttemplate4 version 2.7 to send a mail out of an address administration software to a specified recipient. Smarttemplate4 did not insert the specified mail body (but it did insert the subject defined with %header.set(subject ...), so it is NOT a general issue with Smarttemplate4 not working.
Internet investigation pointed to the fact that Smarttemplate will not insert a body, if the message already contains a body.
For further analysis (if you like) please find below the code of an "empty message" created by my adress administration software:

To: smarttemplate4@posteo.de
From: (me)
Subject: Test Email for issue 33, Smarttemplate4 is deactivated
Message-ID: <0f07dca5-0a93-f3d0-5e14-d6fd92f2d92b@mail.gmx>
Date: Wed, 15 Jan 2020 11:07:01 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.4.1
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: de-DE
@micha917

This comment has been minimized.

Copy link

@micha917 micha917 commented Jan 15, 2020

And the same mail, now with Smarttemplate4 version 2.7 activated, and a sample body specified in Smarttemplate4:

To: smarttemplate4@posteo.de
From: (me)
Subject: Test E-Mail issue 33, Smarttemplate4 active
Message-ID: <994d9f6e-337d-7aa7-8146-7a53b57085a0@mail.gmx>
Date: Wed, 15 Jan 2020 11:00:15 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.4.1
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Language: de-DE
Content-Transfer-Encoding: 8bit

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body smarttemplateinserted="true">
    <div id="smartTemplate4-template"><br>
      <p>Â </p>
    </div>
  </body>
</html>
@micha917

This comment has been minimized.

Copy link

@micha917 micha917 commented Jan 15, 2020

As you can see, something is inserted, but it was not the body I specified.

But thanks to the developer team now the Smarttemplate4 body is inserted as I needed it.
I verified it using the prerelease provided above, smartTemplate-fx-2.8pre106.zip.

@RealRaven2000

This comment has been minimized.

Copy link
Owner Author

@RealRaven2000 RealRaven2000 commented Jan 15, 2020

As you can see, something is inserted, but it was not the body I specified.

But thanks to the developer team

yeah that would be me :)

now the Smarttemplate4 body is inserted as I needed it.
I verified it using the prerelease provided above, smartTemplate-fx-2.8pre106.zip.

that character  looks like an encoding problem, is there any way I can test with the software? If not maybe I can print out the hex code of the body in a debug log

@micha917

This comment has been minimized.

Copy link

@micha917 micha917 commented Jan 17, 2020

In case you like to perform further investigation on this issue with version 2.7 please find attached three files with hex code of sent emails. The first two examples belong to the mails I already posted above.

  1. Test Email for issue 33, smarttemplate deactivated Hex.txt:
    A mail generated by the software and the SmartTemplate addon in Thunderbird is deactivated. You can see two additional CR-LF after the last header line. Maybe in the other cases this is interpreted as "body" by Smarttemplate.
    Test Email for issue 33, smarttemplate deactivated Hex.txt
  2. Test E-Mail issue 33, Smarttemplate4 active Hex.txt:
    Now the same generated mail, but now with SmartTemplate activated. I specified a text body, but that was not inserted. Instead there is a strange hex code (C2 A0) in the body.
    Test E-Mail issue 33, Smarttemplate4 active Hex.txt
  3. Test E-Mail issue 33, Smarttemplate4 active other PC Hex.txt:
    Accidentally I checked the scenario of mail 2 on another PC. And the result is slightly different. SmartTemplate still did not insert the specified body, but the strange hex code is missing. Instead it is just a <br>.
    Test E-Mail issue 33, Smarttemplate4 active other PC Hex.txt

You supposed an encoding problem, and maybe you are right. In mail 2 the header says: Content-Transfer-Encoding: 8bit, and in mail 3 it says: Content-Transfer-Encoding: 7bit.

@RealRaven2000

This comment has been minimized.

Copy link
Owner Author

@RealRaven2000 RealRaven2000 commented Jan 18, 2020

I have done some additional testing and also (luckily) had another support request with a user who transmits a mailto body element containing line breaks, encoded as %0D%0A. In the process, I also found some rogue code that would remove a line break before the signature if followed by a text node. So I would like you to test the latest prerelease to see if you get better results:

smartTemplate-fx-2.8pre178.zip

I can't believe I built 72 versions since the last test! So much work!!

@RealRaven2000

This comment has been minimized.

Copy link
Owner Author

@RealRaven2000 RealRaven2000 commented Jan 20, 2020

2. `Test E-Mail issue 33, Smarttemplate4 active Hex.txt`:
   Now the same generated mail, but now with SmartTemplate activated. I specified a text body, but that was not inserted. Instead there is a strange hex code (C2 A0) in the body.

I looked at your hex dump, and I think it's this:
http://www.fileformat.info/info/unicode/char/00a0/index.htm

Unicode Character 'NO-BREAK SPACE' - 0xC2 0xA0 (c2a0)

so I need to check but I think either Thunderbird or more likely SmartTemplate⁴ may insert a &nbsp; into the empty paragraph, which may actually be overkill. What I did notice before is that the old Mozilla HTML editor of Thunderbird needs a line break in an empty paragraph for it to be shown. They always insert new paragraphs like this:

<p>(cursor)<br/>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.