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 22 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
@github-actions github-actions bot added the stale label Jun 5, 2024
@hishamco
Copy link
Member Author

hishamco commented Jun 5, 2024

I will revise this soon

@hishamco hishamco removed the stale label Jun 5, 2024
# Conflicts:
#	src/OrchardCore.Modules/OrchardCore.Users/Controllers/EmailAuthenticatorController.cs
#	src/OrchardCore.Modules/OrchardCore.Users/Extensions/ControllerExtensions.cs
#	src/OrchardCore.Modules/OrchardCore.Users/Workflows/Activities/RegisterUserTask.cs
#	src/OrchardCore/OrchardCore.Email.Abstractions/MailMessage.cs
#	src/OrchardCore/OrchardCore.Notifications.Core/Services/EmailNotificationProvider.cs
#	src/docs/releases/1.9.0.md
#	test/OrchardCore.Tests/Email/EmailTests.cs
@hishamco
Copy link
Member Author

@MikeKry could you please do one more test if you have time

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.

@MikeAlhayek
Copy link
Member

for instructions on how to resolve the merge conflicts due to #16572 please follow the step listed in this comment.

Copy link
Contributor

It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up.

@github-actions github-actions bot added the stale label Oct 14, 2024
@hishamco
Copy link
Member Author

Seems I need to revisit this soon

@github-actions github-actions bot removed the stale label Oct 15, 2024
Copy link
Contributor

It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up.

@github-actions github-actions bot added the stale label Dec 14, 2024
@sebastienros
Copy link
Member

sebastienros commented Dec 19, 2024

Just a random idea, why not have two tasks, TextEmailTask and HtmlEmailTask. They can have a base class because some people seem to like these ;) and then special case how to render and edit the value.

And since breaking change is important, the current task could keep being what it does by default.

@github-actions github-actions bot removed the stale label Dec 19, 2024
@gvkries
Copy link
Contributor

gvkries commented Dec 20, 2024

Just a random idea, why not have two tasks, TextEmailTask and HtmlEmailTask. They can have a base class because some people seem to like these ;) and then special case how to render and edit the value.

And since breaking change is important, the current task could keep being what it does by default.

I think the main idea here is to have both body types in a single email. Even though it's not that common nowadays, it still is a valid feature IMHO.

@hishamco
Copy link
Member Author

I worked locally on this several days ago to fix the conflict then stopped because I'm sick. Hope to finalize this ASAP

# Conflicts:
#	src/OrchardCore.Modules/OrchardCore.Email/Workflows/Activities/EmailTask.cs
#	src/OrchardCore.Modules/OrchardCore.Email/Workflows/Drivers/EmailTaskDisplayDriver.cs
#	src/OrchardCore.Modules/OrchardCore.Email/Workflows/ViewModels/EmailTaskViewModel.cs
#	src/OrchardCore/OrchardCore.Email.Abstractions/MailMessage.cs
#	test/OrchardCore.Tests/Modules/OrchardCore.Email/Workflows/EmailTaskTests.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

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