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

Add FromName and ReplyTo properties to SmtpSettingsPart #8420

Conversation

aaronamm
Copy link
Contributor

@aaronamm aaronamm commented Sep 25, 2020

Refer to :

I think adding from name, reply to and List-Unsubscribe can help passing an email spam filter.

Therefore, I have updated SmtpSettingsPart to include FromName, ReplyTo and ListUnsubscribe properties.
In addition, I also updated SmtpMessageChannel to make sure everything work correctly.

BTW, I have changed naming convention of fields to not use _ underscore and use a this keyword.
I know it is more convenient to use underscore but I think it is not .NET naming convention.

Hopefully, this PR is valid and will get approved. I am happy to update this PR from your feedback.

Thanks.

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.

Can you also check that the workflow activities don't need to be updated to support these new fields?

@@ -12,12 +11,12 @@
namespace Orchard.Email.Controllers {
[Admin]
public class EmailAdminController : Controller {
private readonly ISmtpChannel _smtpChannel;
private readonly IOrchardServices _orchardServices;
private readonly ISmtpChannel smtpChannel;
Copy link
Member

Choose a reason for hiding this comment

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

Can you revert all the names you changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sebastienros Okay. Since it is naming convention that Orchard team use, I will follow the standard.

@@ -65,6 +72,11 @@
</span>
</div>
</div>
<div>
<label for="@Html.FieldIdFor(m => m.ListUnsubscribe)">@T("List-Unsubscribe header")</label>
Copy link
Member

Choose a reason for hiding this comment

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

Is that something that mail clients understand natively, or just a field that can be used in a template?

Copy link
Contributor Author

@aaronamm aaronamm Oct 6, 2020

Choose a reason for hiding this comment

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

List-Unsubscribe is a STMP header that a mail client can understand natively.
https://www.postmastery.com/list-unsubscribe-header-critical-for-sustained-email-delivery/
It can help an email not go to junk.

Additional information:
https://blog.mailtrap.io/list-unsubscribe-header/#What_is_the_list-unsubscribe_header

@aaronamm
Copy link
Contributor Author

aaronamm commented Oct 6, 2020

Can you also check that the workflow activities don't need to be updated to support these new fields?

I am not familiar with Orchard.WorkFlow area.
However after I search carefully, I did not find any usage of SMTP setting here.
image

There are two main places that use the setting.

  • EmailMessagingChannel I don't update it because it is obsoleted.
  • SmtpMessageChannel the main file that I changed.

@aaronamm
Copy link
Contributor Author

aaronamm commented Oct 6, 2020

@sebastienros Fixed all from your feedback, thank you so much.

@@ -53,7 +53,7 @@ public class EmailMessagingChannel : IMessagingChannel {
smtpClient.EnableSsl = smtpSettings.EnableSsl;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

context.MailMessage.From = new MailAddress(smtpSettings.Address);
context.MailMessage.From = new MailAddress(smtpSettings.FromAddress);
Copy link
Member

Choose a reason for hiding this comment

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

This is an important breaking change, since all existing sites will lose this setting. Maybe a migration step would be good to move the old value to the new properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sebastienros That's a good point, sorry for my mistake. I will continue the work on a migration.
This should be check list item for a contribution note.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update a migration with a test cases result.
However, there is an interesting issue that should fix by other PR.
The existing attribute do not remove from XML after SmtpSettingsPart get updated.
It is still there. I think a serialize XML of saving StmpSettingsPart should be responsible for this.
Therefore, I don't remove it manually.

Could you please check the data after migration in the test case 1.

Test case 1
SmtpSettingPart with existing value before migration

<Data>
    <SiteSettingsPart SiteSalt="fdb3ec855e864eba91d2a3bdfa3c620a" SiteName="orchard-pr" PageTitleSeparator=" - " SiteTimeZone="SE Asia Standard Time" UseFileHash="true" SuperUser="admin" SiteCulture="en-US" PageSize="20" BaseUrl="http://localhost:61745" />
    <CacheSettingsPart VaryByQueryStringIsExclusive="true" />
    <CommentSettingsPart ModerateComments="true" />
    <ThemeSiteSettingsPart CurrentThemeName="TheThemeMachine" />
    <SmtpSettingsPart Address="[email protected]" Host="localhost" Port="25" EnableSsl="false" RequireCredentials="false" UseDefaultCredentials="false" UserName="" Password="" />
</Data>

SmtpSettingPart after migration

<Data>
    <SiteSettingsPart SiteSalt="fdb3ec855e864eba91d2a3bdfa3c620a" SiteName="orchard-pr" PageTitleSeparator=" - " SiteTimeZone="SE Asia Standard Time" UseFileHash="true" SuperUser="admin" SiteCulture="en-US" PageSize="20" BaseUrl="http://localhost:61745" />
    <CacheSettingsPart VaryByQueryStringIsExclusive="true" />
    <CommentSettingsPart ModerateComments="true" />
    <ThemeSiteSettingsPart CurrentThemeName="TheThemeMachine" />
    <SmtpSettingsPart Address="[email protected]" Host="localhost" Port="25" EnableSsl="false" RequireCredentials="false" UseDefaultCredentials="false" UserName="" Password="" FromAddress="[email protected]" />
</Data>

Test case 2
SmtpSettingPart without existing value before migration

<Data>
    <SiteSettingsPart SiteSalt="fdb3ec855e864eba91d2a3bdfa3c620a" SiteName="orchard-pr" PageTitleSeparator=" - " SiteTimeZone="SE Asia Standard Time" UseFileHash="true" SuperUser="admin" SiteCulture="en-US" PageSize="20" BaseUrl="http://localhost:61745" />
    <CacheSettingsPart VaryByQueryStringIsExclusive="true" />
    <CommentSettingsPart ModerateComments="true" />
    <ThemeSiteSettingsPart CurrentThemeName="TheThemeMachine" />
</Data>

SmtpSettingPart after migration

<Data>
    <SiteSettingsPart SiteSalt="fdb3ec855e864eba91d2a3bdfa3c620a" SiteName="orchard-pr" PageTitleSeparator=" - " SiteTimeZone="SE Asia Standard Time" UseFileHash="true" SuperUser="admin" SiteCulture="en-US" PageSize="20" BaseUrl="http://localhost:61745" />
    <CacheSettingsPart VaryByQueryStringIsExclusive="true" />
    <CommentSettingsPart ModerateComments="true" />
    <ThemeSiteSettingsPart CurrentThemeName="TheThemeMachine" />
</Data>

Here is admin panel after a database migration.
image

Sent test email result

image

@aaronamm
Copy link
Contributor Author

@sebastienros Fixed all your PR feedbacks.
Thanks.

@sebastienros sebastienros merged commit 1c93e4a into OrchardCMS:dev Oct 15, 2020
@MatteoPiovanelli-Laser
Copy link
Contributor

@HermesSbicego-Laser @ElenaRepository
Tagging us here to review our email activities/workflows

@aaronamm aaronamm deleted the add-from-name-reply-to-properties-to-smtp-settings-part branch October 16, 2020 18:49
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.

3 participants