Bug 65149 - SMTP sampler doesn't encode header correctly (RFC2047)
Summary: SMTP sampler doesn't encode header correctly (RFC2047)
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.4.1
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER 5.4.1
Assignee: JMeter issues mailing list
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Reported: 2021-02-19 09:22 UTC by Alexander
Modified: 2021-03-01 09:17 UTC (History)
0 users

SMTP-session + MIME (Wireshark) (102.19 KB, image/png)
2021-02-19 09:26 UTC, Alexander
Window from jmeter (26.97 KB, image/png)
2021-02-19 09:32 UTC, Alexander
Try to encode personal parts of email addresses in SMTP Sampler (3.64 KB, patch)
2021-02-20 10:08 UTC, Felix Schumacher
Details | Diff
Wireshark (49.87 KB, image/png)
2021-03-01 09:16 UTC, Alexander
eml (1.44 KB, message/rfc822)
2021-03-01 09:17 UTC, Alexander

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2021-02-19 09:22:55 UTC
When I use cyrillic symbols in strings: "from", "to", "cc", "bcc", jmeter doesn't encode this filds in mime according to https://tools.ietf.org/html/rfc2047.
It just puts this filds in UTF-8, but should use ASCII with special "tags". 

See attach
Comment 1 Alexander 2021-02-19 09:26:47 UTC
Created attachment 37735 [details]
SMTP-session + MIME (Wireshark)
Comment 2 Alexander 2021-02-19 09:32:13 UTC
Created attachment 37736 [details]
Window from jmeter
Comment 3 Felix Schumacher 2021-02-20 10:08:20 UTC
Created attachment 37737 [details]
Try to encode personal parts of email addresses in SMTP Sampler

Currently JMeter thinks, that the creator of the test plan encodes their email addresses used in SMTP Sampler themselves. That is a bit uncomfortable and I think, we can do better.
The attached patch tries to guess if encoding is needed and which part of the email should be encoded.

Note, that it only tries to encode the personal part, which is everything before a potentially existing '<'. If the real address contains umlauts, the creator of the test plan is still responsible to encode those.
Comment 4 Felix Schumacher 2021-02-20 10:09:09 UTC
@Alexander, can you try the attached patch and report, if it suits your needs?
Comment 5 Alexander 2021-02-20 11:01:24 UTC
@Felix firstly thnx for fast reply.
I had not guess that I realy can encode those fields myself. I have tried to do this and it workes.

I am a new member. Could you explain how can I apply your patch? First thougth is to go to your git, download src'es and make the same changes. After that I should make new build and try this fixes. Am I right? 
Is there any simpler case? )
Comment 6 Felix Schumacher 2021-02-20 12:47:30 UTC
To make it easier for you to test the patch (though it can be applied with `git am PATH-TO-THE-PATCH`) I have submitted a PR (https://github.com/apache/jmeter/pull/644).

To get the PRs locally, you have to edit the .git/config file inside the cloned repo. Add "fetch = +refs/pull/*/head:refs/remotes/origin/pr/*" under the section "[remote "origin"]". Next time you do a git pull, you should see all PRs.

To checkout pr/644, build and run it,

$ git pull && git checkout pr/644 && ./gradlew runGui

should do the trick.
Comment 7 Felix Schumacher 2021-02-27 16:11:43 UTC
@Alexander, could you test next nightly or build from trunk?

commit d10b0e54bc2450a0ebd908c28380a91c08e795aa
AuthorDate: Sat Feb 20 11:03:02 2021 +0100

    Encode the personal part of email addresses in SMTP Sampler
    Often those personal parts contain umlauts. Try to find these
    and let MimeUtility encode those as quoted encodings.
    Bugzilla Id: 65149
    Closes #644 on github
 .../jmeter/protocol/smtp/sampler/SmtpSampler.java  | 23 ++++++++++++++++++++--
 xdocs/changes.xml                                  |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
Comment 8 Alexander 2021-03-01 08:25:55 UTC
Hello, Felix! Sorry for silence.
Unfortunately, I had no any time for testing. I will try to test today
Comment 9 Alexander 2021-03-01 09:11:29 UTC
I have tried "LATEST (r2015-d10b0e54bc2450a0ebd908c28380a91c08e795aa)"
Looks like everithing is ok. I sent messages: with cyrilic symbols (with quotes and without) and with regular latin symbols. Cyrilic text was printable encoded. I recieved readable 'from', 'to', 'cc' in messages.
Comment 10 Alexander 2021-03-01 09:16:36 UTC
Created attachment 37751 [details]
Comment 11 Alexander 2021-03-01 09:17:07 UTC
Created attachment 37752 [details]
Comment 12 The ASF infrastructure team 2022-09-24 20:38:21 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5501