[GH-ISSUE #218] [Bug] EMails in<mail@world.org> Format cause Problems #178

Closed
opened 2026-02-25 21:34:21 +03:00 by kerem · 14 comments
Owner

Originally created by @ulfgebhardt on GitHub (Aug 24, 2017).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/218

Originally assigned to: @jasonmunro on GitHub.

Hi,

EMails in the Format <peter@world.og> cause Problems.

  • In "Sent" Dialog the "Sent-to" where the Address or name shows is empty, inspect reveals its actually empty when EMails are in the "<peter@world.og>" Format. See Exhibit A

  • Sometimes when composing new Mails with "<peter@world.og>" in the address will make the EMail not send correctly and not show up under Sent at all < thats particular anoying.

  • When sending to those Addresses Attachments fail to transmit quite frequently

  • Those Addresses do not match towards the Local Addressbook (could also be a multi-recipient thingy) and apear without a name, just "<peter@world.og>"

  • EMails with " "Peter" <peter@world.org>" work correctly

This behaviour often occurs when sending to multiple recipients.

Revision: 5f2d5c5f8e2f9083c84d795b8337ffc403eab42f

A wild guess - which might not be helpful at all - it could be escaping - html uses <> - htmlentities

Thanks for your Effort - its great Software - I use it <3

Grüße Ulf

Exhibit A:
crypht

Exhibit B:
crypht2

<3

Originally created by @ulfgebhardt on GitHub (Aug 24, 2017). Original GitHub issue: https://github.com/cypht-org/cypht/issues/218 Originally assigned to: @jasonmunro on GitHub. Hi, EMails in the Format &lt;peter@world.og> cause Problems. - In "Sent" Dialog the "Sent-to" where the Address or name shows is empty, inspect reveals its actually empty when EMails are in the "&lt;peter@world.og>" Format. See Exhibit A - Sometimes when composing new Mails with "&lt;peter@world.og>" in the address will make the EMail not send correctly and not show up under Sent at all < thats particular anoying. - When sending to those Addresses Attachments fail to transmit quite frequently - Those Addresses do not match towards the Local Addressbook (could also be a multi-recipient thingy) and apear without a name, just "&lt;peter@world.og>" - EMails with " "Peter" &lt;peter@world.org>" work correctly This behaviour often occurs when sending to multiple recipients. Revision: [5f2d5c5f8e2f9083c84d795b8337ffc403eab42f](https://github.com/jasonmunro/cypht/commit/5f2d5c5f8e2f9083c84d795b8337ffc403eab42f) A wild guess - which might not be helpful at all - it could be escaping - html uses &lt;> - [htmlentities](http://php.net/manual/en/function.htmlentities.php) Thanks for your Effort - its great Software - I use it <3 Grüße Ulf Exhibit A: ![crypht](https://user-images.githubusercontent.com/1238238/29682832-bdfa7ecc-890c-11e7-8c27-162bf8bca3f1.png) Exhibit B: ![crypht2](https://user-images.githubusercontent.com/1238238/29683169-b24a69c4-890d-11e7-87ee-02ecee060bf9.png) <3
kerem 2026-02-25 21:34:21 +03:00
  • closed this issue
  • added the
    bug
    smtp
    labels
Author
Owner

@ulfgebhardt commented on GitHub (Aug 24, 2017):

EMail with two <peter@world.org> Addresses - one in "From" other in "CC"

crypht3

Reply ommits the EMail from "From" Field. "To" Field is empty.

crypht4

Header:
X-Mailer | Microsoft Office Outlook 12.0
^
Who else could it be? ^^

Recipients from my local Address-Book show up as peter@my.local.mailserver in the CC. Additional the original Address is listed

crypht5

EMail is not sent when you use this in CC:
<"'peter@world.org'">, <"petra@world.org">, <'"petuna@world.org"'>

Doublequote Singlequote > Doublequote > Singlequote Doublequote

I know this might not be mail-conform, or maybe even a server problem - but i would like to be warned when i try 2 send emails to malformed mails like those Quote-Doublequote Stuff. When sending to those i get "Message Sent" -> does not reach destination > is not listed in "Sent" > reaches Destination partialy (in my testcase the "To" Field was set to smth valid > and found its destination)

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_windows8/how-do-i-stop-outlook-from-adding-single-quotation/ad0969ac-22bb-4259-8c2f-7730188d5d80

https://stackoverflow.com/questions/4816424/are-single-quotes-legal-in-the-name-part-of-an-email-address

Suggestions:

  1. Remove <> when the EMail is not in " "Peter" <peter@world.org>" Format
  2. Remove Signlequotes around an EMail if its on both ends

Remove on <'peter@world.org'>
Do not remove on <'peter@world.org> since its a valid EMail

<3

<!-- gh-comment-id:324780743 --> @ulfgebhardt commented on GitHub (Aug 24, 2017): EMail with two &lt;peter@world.org> Addresses - one in "From" other in "CC" ![crypht3](https://user-images.githubusercontent.com/1238238/29692574-1a2b2e70-8931-11e7-9e89-2d36f9b4b093.png) Reply ommits the EMail from "From" Field. "To" Field is empty. ![crypht4](https://user-images.githubusercontent.com/1238238/29692576-1c1819fa-8931-11e7-9cd1-9ea546d43642.png) Header: X-Mailer | Microsoft Office Outlook 12.0 ^ Who else could it be? ^^ Recipients from my local Address-Book show up as peter@my.local.mailserver in the CC. Additional the original Address is listed ![crypht5](https://user-images.githubusercontent.com/1238238/29693132-3d5ab142-8934-11e7-8e47-804f84b1f8a8.png) EMail is not sent when you use this in CC: &lt;"'peter@world.org'">, &lt;"petra@world.org">, &lt;'"petuna@world.org"'> > Doublequote Singlequote > Doublequote > Singlequote Doublequote I know this might not be mail-conform, or maybe even a server problem - but i would like to be warned when i try 2 send emails to malformed mails like those Quote-Doublequote Stuff. When sending to those i get "Message Sent" -> does not reach destination > is not listed in "Sent" > reaches Destination partialy (in my testcase the "To" Field was set to smth valid > and found its destination) https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_windows8/how-do-i-stop-outlook-from-adding-single-quotation/ad0969ac-22bb-4259-8c2f-7730188d5d80 https://stackoverflow.com/questions/4816424/are-single-quotes-legal-in-the-name-part-of-an-email-address Suggestions: 1. Remove &lt;> when the EMail is not in " "Peter" &lt;peter@world.org>" Format 2. Remove Signlequotes around an EMail if its on both ends > Remove on &lt;'peter@world.org'> > Do not remove on &lt;'peter@world.org> since its a valid EMail <3
Author
Owner

@jasonmunro commented on GitHub (Aug 25, 2017):

I appreciate the thorough feedback on this! Just to make sure I understand the issue:

  • recipient addresses of the form <"address"> are not delivered to (double or single quotes or both)
  • when sending to more than one recipient, we silently fail on malformed addresses and only send to the valid ones

from what I recall, the form <"address"> is not a valid format. quotes are allowed in the local name portion of an address, but not the domain part. Not to say I won't try to make it work :) I believe servers should be strict about adhering to protocol standards, but clients should be forgiving with regards to what they accept.

The second problem is a bit trickier to handle. We parse the recipient address fields and try to pull out valid address parts, I'm not sure if we can accurately detect that we found a malformed address, but I will look into the code and see what we can do.

Thanks again for the feedback!

<!-- gh-comment-id:324968692 --> @jasonmunro commented on GitHub (Aug 25, 2017): I appreciate the thorough feedback on this! Just to make sure I understand the issue: - recipient addresses of the form <"address"> are not delivered to (double or single quotes or both) - when sending to more than one recipient, we silently fail on malformed addresses and only send to the valid ones from what I recall, the form <"address"> is not a valid format. quotes are allowed in the local name portion of an address, but not the domain part. Not to say I won't try to make it work :) I believe servers should be strict about adhering to protocol standards, but clients should be forgiving with regards to what they accept. The second problem is a bit trickier to handle. We parse the recipient address fields and try to pull out valid address parts, I'm not sure if we can accurately detect that we found a malformed address, but I will look into the code and see what we can do. Thanks again for the feedback!
Author
Owner

@jasonmunro commented on GitHub (Aug 25, 2017):

Just pushed an update in b9dd0e697 to deal with at least the first problem (which makes the second issue less important I think). Address line parsing to find recipients now works like this:

  • We use a regex to match the following pattern: [one or more non-whitespace]@[one or more non-whitespace]
  • we loop through these matches, and trim commas or semi-colons from the start and end if they exist
  • if the first character is a single or double quote, we skip it since it's quoted which means it's not an address
  • we then trim angle brackets, single, and double quotes from the start and end
  • then we check if the remaining part is a valid e-mail address per the spec (rfc 3696)

This is still not bullet proof, but it should be better and I think it will fix your situation.

<!-- gh-comment-id:324985628 --> @jasonmunro commented on GitHub (Aug 25, 2017): Just pushed an update in b9dd0e697 to deal with at least the first problem (which makes the second issue less important I think). Address line parsing to find recipients now works like this: - We use a regex to match the following pattern: [one or more non-whitespace]@[one or more non-whitespace] - we loop through these matches, and trim commas or semi-colons from the start and end if they exist - if the first character is a single or double quote, we skip it since it's quoted which means it's not an address - we then trim angle brackets, single, and double quotes from the start and end - then we check if the remaining part is a valid e-mail address per the spec (rfc 3696) This is still not bullet proof, but it should be better and I think it will fix your situation.
Author
Owner

@ulfgebhardt commented on GitHub (Aug 25, 2017):

To define the Problem more correct:

  • I think <"peter@world.org"> delivers properly, but has display problems.
  • Double+Single-Quotes fail to deliver silently when in cc - which is actually correct(except the silent part) since Single-Quote is a valid Part of an EMail, but the Origin is Microsoft Office so we should address the Issue, as you said, afterall it is quite common Software.

A Test would be:

<"'peter@world.org'">, <"petra@world.org">, <'"petuna@world.org"'>
as To or CC Value. Note, I have never seen the last Part with Single+Double-Quote.

Regarding parsing the To or CC Field my approach would be the following:

  • explode(',',$field)
  • regex [validrecipientchars]@[validdomain+singlequoteAtTheEnd]
  • if first & last char is singlequote -> trim it

But you have better Overview over this.
I will update tonight and give Feedback.

<3

<!-- gh-comment-id:325035708 --> @ulfgebhardt commented on GitHub (Aug 25, 2017): To define the Problem more correct: - I think &lt;"peter@world.org"> delivers properly, but has display problems. - Double+Single-Quotes fail to deliver silently when in cc - which is actually correct(except the silent part) since Single-Quote is a valid Part of an EMail, but the Origin is Microsoft Office so we should address the Issue, as you said, afterall it is quite common Software. A Test would be: > <"'peter@world.org'">, <"petra@world.org">, <'"petuna@world.org"'> as To or CC Value. Note, I have never seen the last Part with Single+Double-Quote. Regarding parsing the To or CC Field my approach would be the following: - explode(',',$field) - regex [validrecipientchars]@[validdomain+singlequoteAtTheEnd] - if first & last char is singlequote -> trim it But you have better Overview over this. I will update tonight and give Feedback. <3
Author
Owner

@ulfgebhardt commented on GitHub (Aug 25, 2017):

Sending works properly now!

Tested the following:
<"peter@world.org">, <'peter@world.org'>, "'peter'" <"'peter@world.org'">, <"'peter@world.org'">

A few issues remain

  • Display "To"-Field in "Sent" is still empty on some occasions
  • When inspecting an EMail under "Sent" The "To" and "CC"-Field contain

"Peter"@mail.world.org, peter@world.org
<"some@address.com"@mail.world.org>
This seems to apply to Addresses in the local Address book

<3

<!-- gh-comment-id:325039994 --> @ulfgebhardt commented on GitHub (Aug 25, 2017): Sending works properly now! Tested the following: &lt;"peter@world.org">, &lt;'peter@world.org'>, "'peter'" &lt;"'peter@world.org'">, <"'peter@world.org'"> A few issues remain - Display "To"-Field in "Sent" is still empty on some occasions - When inspecting an EMail under "Sent" The "To" and "CC"-Field contain > "Peter"@mail.world.org, peter@world.org > &lt;"some@address.com"@mail.world.org> > This seems to apply to Addresses in the local Address book <3
Author
Owner

@jasonmunro commented on GitHub (Aug 25, 2017):

Thanks for the follow up. Before I changed the code I tested a few things, specifically trying to send to addresses of the format:

<"address">
<'address'>

Both failed for different reasons. The double quotes failed because the code removed contents in quotes since that is not supposed to be used for addresses (for the most part). The single quotes failed because having a single quote in the domain part is invalid. I did not have any issues with <address> (no quotes), and I did not try having both since I knew just one type of quote would fail.

What I implemented is not totally unlike your approach, just a bit more generalized. It's only flaw that I know of is " notanaddress@blah.com " someother@address.com. It will try to send to notanaddress@blah.com and the actual address (note it needs to have that space before the first double quote and the address, or more precisely, not have a quote before the first char of the local part of the address in quotes). The change successfully deals with quotes inside the angle brackets, both double and single. Keep in mind it's a 2 step process: 1. find what we think are addresses, and 2. validate them against the rfc.

Step 1 is done here:
https://github.com/jasonmunro/cypht/blob/master/modules/smtp/hm-mime-message.php#L154
Step 2 is done here:
https://github.com/jasonmunro/cypht/blob/master/modules/core/functions.php#L166

You are correct that I did not deal with display issues yet, now that I can send addresses with this quoting style I can more easily test and fix that :) Just saw your new reply, glad it's working better. I will update again when I resolve the display issues.

Really appreciate the feedback and testing!

<!-- gh-comment-id:325040183 --> @jasonmunro commented on GitHub (Aug 25, 2017): Thanks for the follow up. Before I changed the code I tested a few things, specifically trying to send to addresses of the format: &lt;"address"&gt; &lt;'address'&gt; Both failed for different reasons. The double quotes failed because the code removed contents in quotes since that is not supposed to be used for addresses (for the most part). The single quotes failed because having a single quote in the domain part is invalid. I did not have any issues with &lt;address&gt; (no quotes), and I did not try having both since I knew just one type of quote would fail. What I implemented is not totally unlike your approach, just a bit more generalized. It's only flaw that I know of is " notanaddress@blah.com " someother@address.com. It will try to send to notanaddress@blah.com and the actual address (note it needs to have that space before the first double quote and the address, or more precisely, not have a quote before the first char of the local part of the address in quotes). The change successfully deals with quotes inside the angle brackets, both double and single. Keep in mind it's a 2 step process: 1. find what we think are addresses, and 2. validate them against the rfc. Step 1 is done here: https://github.com/jasonmunro/cypht/blob/master/modules/smtp/hm-mime-message.php#L154 Step 2 is done here: https://github.com/jasonmunro/cypht/blob/master/modules/core/functions.php#L166 You are correct that I did not deal with display issues yet, now that I can send addresses with this quoting style I can more easily test and fix that :) Just saw your new reply, glad it's working better. I will update again when I resolve the display issues. Really appreciate the feedback and testing!
Author
Owner

@jasonmunro commented on GitHub (Aug 25, 2017):

also I have not tried to enhance the sending logic such that if one recipient is invalid, you are notified or the sending is halted. I could check that any address found in step 1 that fails in step 2 means we should halt sending and warn the user. Still not sure that's the best way to deal with it, but it might be better than nothing (it might catch obvious typos at least).

<!-- gh-comment-id:325040797 --> @jasonmunro commented on GitHub (Aug 25, 2017): also I have not tried to enhance the sending logic such that if one recipient is invalid, you are notified or the sending is halted. I could check that any address found in step 1 that fails in step 2 means we should halt sending and warn the user. Still not sure that's the best way to deal with it, but it might be better than nothing (it might catch obvious typos at least).
Author
Owner

@ulfgebhardt commented on GitHub (Aug 25, 2017):

Thanks for the quick update! Really appreciate that.

I try to give the best possible Feedback, so its easier for you to solve the Problem. Its a win-win ;-). You make great Software and deserve good Feedback to enhance it.

Regarding the sending logic:
It is irritating that you can send an EMail which partly fails to deliver but the Message "Message sent" pops up. It would be better to have it say "Failed to send Message(partly)" and keep the Compose open including content.
An Idea is to send the local copy first(to the Sent-Folder) to make sure you can send it again, even on fail. But currently the missing Mail in Sent is the only way to tell if a Message is not transmitted completly.

Another display thing I described above alrdy, but copied it down so its not lost:

When inspecting an EMail under "Sent" The "To" and "CC"-Field contain

"Peter"@mail.world.org, peter@world.org
<"some@address.com"@mail.world.org>
This seems to apply to Addresses in the local Address book

This might be an Serverproblem - i cannot tell yet. If you like I can make a seperate Issue for that.

Looking at is_email_address this could be caused by an "is-local-detection" false positiv

Grüße Ulf

<3

<!-- gh-comment-id:325044679 --> @ulfgebhardt commented on GitHub (Aug 25, 2017): Thanks for the quick update! Really appreciate that. I try to give the best possible Feedback, so its easier for you to solve the Problem. Its a win-win ;-). You make great Software and deserve good Feedback to enhance it. Regarding the sending logic: It is irritating that you can send an EMail which partly fails to deliver but the Message "Message sent" pops up. It would be better to have it say "Failed to send Message(partly)" and keep the Compose open including content. An Idea is to send the local copy first(to the Sent-Folder) to make sure you can send it again, even on fail. But currently the missing Mail in Sent is the only way to tell if a Message is not transmitted completly. ~~Another display thing I described above alrdy, but copied it down so its not lost:~~ ~~When inspecting an EMail under "Sent" The "To" and "CC"-Field contain~~ > "Peter"@mail.world.org, peter@world.org > &lt;"some@address.com"@mail.world.org> > This seems to apply to Addresses in the local Address book ~~This might be an Serverproblem - i cannot tell yet. If you like I can make a seperate Issue for that.~~ > Looking at [is_email_address](https://github.com/jasonmunro/cypht/blob/master/modules/core/functions.php#L166) this could be caused by an "is-local-detection" false positiv Grüße Ulf <3
Author
Owner

@jasonmunro commented on GitHub (Aug 28, 2017):

Should have some time to fix the display issues around this tomorrow. Still working out how I want to handle the "failed to send to all recipients issue". After I fix the display bugs I think I will close this and open a new issue for that specific problem.

<!-- gh-comment-id:325505733 --> @jasonmunro commented on GitHub (Aug 28, 2017): Should have some time to fix the display issues around this tomorrow. Still working out how I want to handle the "failed to send to all recipients issue". After I fix the display bugs I think I will close this and open a new issue for that specific problem.
Author
Owner

@ulfgebhardt commented on GitHub (Sep 7, 2017):

I somehow still have trouble sending EMail - they do not reach destination on some unknown occasions :(

I think it might be space related:

  1. have an Email with "From" Field value

"Peter Worldcitizen" <peter@world.org>

  1. Press reply
  2. EMail does not appear in "To" Field in the newly opened Compose

Grüße Ulf

<3

<!-- gh-comment-id:327770080 --> @ulfgebhardt commented on GitHub (Sep 7, 2017): I somehow still have trouble sending EMail - they do not reach destination on some unknown occasions :( I think it might be space related: 1. have an Email with "From" Field value `"Peter Worldcitizen" <peter@world.org>` 2. Press reply 3. EMail does not appear in "To" Field in the newly opened Compose Grüße Ulf <3
Author
Owner

@jasonmunro commented on GitHub (Sep 7, 2017):

Sorry I have not had time to dig into your issues here, been super busy with work this past week. I have not run into this issue - I'm going to try to reproduce it now.

<!-- gh-comment-id:327929726 --> @jasonmunro commented on GitHub (Sep 7, 2017): Sorry I have not had time to dig into your issues here, been super busy with work this past week. I have not run into this issue - I'm going to try to reproduce it now.
Author
Owner

@jasonmunro commented on GitHub (Sep 12, 2017):

@ulfgebhardt I merged some address parsing code paths that I think will resolve the issue of the E-mail not showing up in the reply fields. I'm unable to reproduce this problem unless I have an invalid format (quotes inside the angle brackets), but this merge should fix that as well.

<!-- gh-comment-id:328974537 --> @jasonmunro commented on GitHub (Sep 12, 2017): @ulfgebhardt I merged some address parsing code paths that I think will resolve the issue of the E-mail not showing up in the reply fields. I'm unable to reproduce this problem unless I have an invalid format (quotes inside the angle brackets), but this merge should fix that as well.
Author
Owner

@ulfgebhardt commented on GitHub (Sep 13, 2017):

Mostly fixed.

Two Things Remain:

Problem 1:

  1. "peter@world.org" <peter@world.org> in CC
  2. reply all
  3. "peter@world.org>" <peter@world.org> in Compose CC (note the trailing >)

Problem 2:

  1. Have Email in sent with To-Field = <peter@world.org>,<petra@world.org>
  2. Sent-List displays a comma in To-Field but no values: ","

Rev: 26a3870e58

Grüße Ulf

<3

<!-- gh-comment-id:329083976 --> @ulfgebhardt commented on GitHub (Sep 13, 2017): Mostly fixed. Two Things Remain: Problem 1: 1. "peter@world.org" &lt;peter@world.org> in CC 2. reply all 3. "peter@world.org>" &lt;peter@world.org> in Compose CC (note the trailing >) Problem 2: 1. Have Email in sent with To-Field = &lt;peter@world.org>,&lt;petra@world.org> 2. Sent-List displays a comma in To-Field but no values: "," Rev: 26a3870e58702787c0b8356863b8c4108a9bf1d7 Grüße Ulf <3
Author
Owner

@ulfgebhardt commented on GitHub (Jan 2, 2018):

Clsoing in Favor of #246

<!-- gh-comment-id:354895669 --> @ulfgebhardt commented on GitHub (Jan 2, 2018): Clsoing in Favor of #246
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#178
No description provided.