-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Newlines from body stripped in some configurations #11
Comments
Disclaimer: I'm not actually using this lib, but came across the blog post mentioning it, when troubleshooting issues sending e-mails. This project is a great way to try out different approaches. I'm convinced it's not possible to have newlines working properly in all configurations! (By configuration, I mean phone model + android version + email client). Depending on how the intent is created, either some configurations will have newlines stripped (like gmail here), or some different configurations will have literal diff --git a/library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java b/library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java
index ccc1687..eb0dfc4 100644
--- a/library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java
+++ b/library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java
@@ -335,6 +335,6 @@ public final class EmailIntentBuilder {
@NotNull
static String fixLineBreaks(String text) {
- return text.replaceAll("\r\n", "\n").replace('\r', '\n').replaceAll("\n", "\r\n");
+ return text.replaceAll("\r\n", "\n").replace('\r', '\n').replaceAll("\n", "<br>\r\n");
}
} But I'd be happy to be proved wrong 😅 If not, I guess the approach should be to find a solution that:
|
Here's some test results that can maybe help. These were testing our app, which doesn't use this library, but it basically does the same thing as this library does in The first table is doing what the library does. The second table is with the patch to include the What this library does:
Details:
Patch to include
Details:
|
The specification for mailto URIs is clear. The body parameter is plain text. Every app that interprets text like Gmail used to work fine. At some point, probably earlier this year, they broke their mailto URI handling code (see issue #8). I'm guessing they fixed it, but some Android versions and/or devices still get a buggy version. I'd strongly recommend against using |
Thanks for the feedback! Actually I didn't mention that in addition to the full Uri (with to, subject, and body), we also send We've opted to not include the Note that I did play around with removing the body from the uri and only specifying it in |
btw, indeed the "missing newlines" issue only appeared in Gmail. We also tested other mail clients like samsung mail and outlook too, it's mentioned in the tables in the previous comment. I hadn't noticed that it was only Gmail which had this problem. Thanks for the reference to #8 |
I don't consider that page to be part of the API documentation. It's just a guide created by people at Google who probably made the same mistakes as the rest of the internet (consult StackOverflow rather than the API documentation). FWIW I'm all for changing the API documentation to reflect the reality that everyone is using these extras. But I haven't been successful so far (see https://issuetracker.google.com/issues/36946106). |
On a Samsung Galaxy S8, Android 9 (and maybe other configurations), newlines aren't included when selecting Gmail. They are included when selecting the default Samsung mail app.
Steps to reproduce:
Screenshots:
Sample app:
Gmail missing newlines:
Samsung mail app contains newlines ok:
The text was updated successfully, but these errors were encountered: