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

Support both Text & HTML in the same email #14715

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

hishamco
Copy link
Member

@hishamco hishamco commented Nov 17, 2023

/cc @MikeKry

@hishamco hishamco mentioned this pull request Nov 17, 2023
@hishamco
Copy link
Member Author

@Mike4tel could you please try to send via EmailTask all the 3 cases to ensure it was similar to the old behavior. Also, I might add unit tests too

@MikeKry
Copy link
Contributor

MikeKry commented Nov 25, 2023

@hishamco
Thanks for looking at this. Code looks good and I have tested all 3 scenarios.

Html - OK
Text - OK
"All" (may be renamed to multipart/alternative or something) - Works OK (as seen below). Just one more thing. There is need to have two Body fields - text and html (similar as it was before). Because you need to have different formatting in text and html.

image

@hishamco
Copy link
Member Author

hishamco commented Nov 25, 2023

"All" (may be renamed to multipart/alternative or something)

All or Both make sense to me

There is need to have two Body fields - text and html (similar as it was before). Because you need to have different formatting in text and HTML.

This will revert the changes and let the body TextBody & HtmlBody

@hishamco
Copy link
Member Author

@sebastienros are we fine to add two bodies into the MailMessage or shall we let the sender decide if the body is HTML or Text

One option if we use MailMessageFormat.All is to supply the HTML body and then stripe all the HTML tags to make it fine for the plain-text body. This way we can use a single body instead of two

@Mike4tel
Copy link

Mike4tel commented Nov 25, 2023

Just pointing out that only stripping html will not let users format text nicely for plain text.. it is needed for good marketing.

But I can see using stripped html version as another feature just to fight spam filters.

@hishamco hishamco requested a review from agriffard as a code owner November 27, 2023 12:13
@MikeKry
Copy link
Contributor

MikeKry commented Jan 20, 2024

Is it possible to merge this one? :)

@hishamco
Copy link
Member Author

We forgot this one :) I will do a final review and then merge

@hishamco hishamco requested review from MikeAlhayek and removed request for agriffard January 20, 2024 21:29
Copy link
Member

@MikeAlhayek MikeAlhayek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hishamco what is the problem that you are trying to solve? Why would we need All as an enum value?

Maybe we should have an interface for the message like INotificationMessage which we already have. Or something similar

public interface IEmailMessage 
{
    string Message { get; }
    bool IsHtml { get; }
}

@hishamco
Copy link
Member Author

hishamco commented Jan 21, 2024

Maybe we should have an interface for the message like INotificationMessage which we already have. Or something similar

I don't think so, the issue was the email can be sent in both formats. In the past we already had IsHtml but it didn't fit anymore, that's why I introduced something similar to the MimiKit mail body

Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

# Conflicts:
#	src/OrchardCore.Modules/OrchardCore.Email/Controllers/AdminController.cs
#	src/OrchardCore.Modules/OrchardCore.Users/Controllers/EmailAuthenticatorController.cs
#	src/OrchardCore/OrchardCore.Email.Core/Services/SmtpService.cs
@hishamco
Copy link
Member Author

hishamco commented Jan 4, 2025

@MikeKry could please do one more test, this PR takes so long, we need to review it and merge it ASAP

src/docs/releases/2.0.0.md Outdated Show resolved Hide resolved
@hishamco hishamco requested a review from gvkries January 21, 2025 23:02
Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be some kind of migration for existing email tasks. Currently, any existing email body is lost when I edit an existing mail task.

mode: { name: "liquid" },
});

$('select').onchange(function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for me either. Shouldn't this be like on('change,...)?
Additionally, I think the select element needs its own id.

@hishamco
Copy link
Member Author

Let me check

@hishamco hishamco requested a review from gvkries January 25, 2025 01:26
@hishamco
Copy link
Member Author

There needs to be some kind of migration for existing email tasks. Currently, any existing email body is lost when I edit an existing mail task.

I might not work extensively on workflow, I'm not sure how we can achieve that, feel free to add a commit in the PR

Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still many issues at the moment in this PR. E.g. the UI is broken in the workflow editor, because the state of the selected body types is not restored. Also the code mirror editors are not working correctly, if they are initialized on a hidden input field.

hishamco and others added 4 commits January 31, 2025 03:09
@hishamco hishamco requested a review from gvkries February 8, 2025 18:26
Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is much simpler and better now.

But I still have the issue with the workflow task editor, where switching between HTML and Text only is not working correctly. I suggest that we just show both editors all the time and skip having to select between text/html/all.

src/docs/releases/3.0.0.md Outdated Show resolved Hide resolved
Co-authored-by: Georg von Kries <gvk@creativbox.net>
@hishamco
Copy link
Member Author

hishamco commented Feb 9, 2025

But I still have the issue with the workflow task editor, where switching between HTML and Text only is not working correctly. I suggest that we just show both editors all the time and skip having to select between text/html/all.

I will revise the workflow one more time

Copy link
Member

@sebastienros sebastienros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow editor should provide two tabs or fields (with one collapsed by default?) for users to provide both values at all times. Either they provide 0, 1 or 2 contents then we just flow these values to the BodyMessage. We can pass null in the html/text argument if the text is empty (but not whitespace).

/// <param name="body">The email body.</param>
/// <param name="isHtmlBody">Whether the <paramref name="body"/> is in HTML format or not. Defaults to <c>true</c>.</param>
/// <returns></returns>
/// <param name="htmlBody">The email body in HTML format.</param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments should say the values are optional (can be null). Maybe use the ? operator to be specific.

@hishamco
Copy link
Member Author

hishamco commented Feb 14, 2025

The workflow editor should provide two tabs or fields (with one collapsed by default?) for users to provide both values at all times. Either they provide 0, 1 or 2 contents then we just flow these values to the BodyMessage. We can pass null in the html/text argument if the text is empty (but not whitespace).

The current implementation allows the user to either use HTML or Text or both

EmailTask.mp4

@hishamco
Copy link
Member Author

@gvkries please check the above video

@gvkries
Copy link
Contributor

gvkries commented Feb 14, 2025

@hishamco As said:

  1. You don't restore the dropdown state when editing an existing task. It always selects text by default.
  2. If you're editing an task where you had HTML selected before, the whole code mirror editor breaks down. I guess this happens because the editor gets initialized on a hidden input field, but I don't know:
    E.g. it doesn't show the HTML at all:
    image
    After clicking into the editor, it shows up but is still broken:
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants