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

feat: support default email feature via portal config #3415

Merged
merged 1 commit into from
Dec 12, 2020

Conversation

nisiyong
Copy link
Member

@nisiyong nisiyong commented Dec 7, 2020

What's the purpose of this PR

Apollo already has supported to integration email feature, but it needs developers to implement it by themselves.
For easier use of Apollo, I modified the DefaultEmailService, so users could enjoy the email notification feature by just add some configurations at the portal.

Properties users concerned as follows:

  • email.enabled, set true to enable email feature.
  • email.config.host, the SMTP server address.
  • email.config.user, the SMTP auth user.
  • email.config.password, the SMTP auth password.
  • email.supported.envs, supported ENVs.

And the properties as follows I think they should have default values unless they want to modify:

  • email.sender, the default value is same as email.config.user
  • email.template.framework
<html><head><style type="text/css">.table{width:100%;max-width:100%;margin-bottom:20px;border-collapse:collapse;background-color:transparent}td{padding:8px;line-height:1.42857143;vertical-align:top;border:1px solid #ddd;border-top:1px solid #ddd}.table-bordered{border:1px solid #ddd}</style></head><body><h3>发布基本信息</h3><table class="table table-bordered"><tr><td width="10%"><b>AppId</b></td><td width="15%">#{appId}</td><td width="10%"><b>环境</b></td><td width="15%">#{env}</td><td width="10%"><b>集群</b></td><td width="15%">#{clusterName}</td><td width="10%"><b>Namespace</b></td><td width="15%">#{namespaceName}</td></tr><tr><td><b>发布者</b></td><td>#{operator}</td><td><b>发布时间</b></td><td>#{releaseTime}</td><td><b>发布标题</b></td><td>#{releaseTitle}</td><td><b>备注</b></td><td>#{releaseComment}</td></tr></table>#{diffModule}#{rulesModule}<br><a href="#{apollo.portal.address}/config/history.html?#/appid=#{appId}&env=#{env}&clusterName=#{clusterName}&namespaceName=#{namespaceName}&releaseHistoryId=#{releaseHistoryId}">点击查看详细的发布信息</a><br><br>如有Apollo使用问题请先查阅<a href="https://github.com/ctripcorp/apollo/wiki">文档</a>,或直接回复本邮件咨询。</body></html>
  • email.template.release.module.diff
<h3>变更的配置</h3>
<table class="table table-bordered">
    <tr>
        <td width="10%"><b>Type</b></td>
        <td width="20%"><b>Key</b></td>
        <td width="35%"><b>Old Value</b></td>
        <td width="35%"><b>New Value</b></td>
    </tr>
    #{diffContent}
</table>
  • email.template.rollback.module.diff
<h3>变更的配置</h3>
<table class="table table-bordered">
    <tr>
        <td width="10%"><b>Type</b></td>
        <td width="20%"><b>Key</b></td>
        <td width="35%"><b>回滚前</b></td>
        <td width="35%"><b>回滚后</b></td>
    </tr>
    #{diffContent}
</table>
  • email.template.release.module.rules
<h3>灰度规则</h3>
#{rulesContent}
<br>

Which issue(s) this PR fixes:

Brief changelog

  • add maven dependency javax.mail in the portal.
  • support some new configs in the portal.
  • modify EmailService from the empty implementation to the SMTP implementation.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.

SMTPTransport t = null;
try {
Properties prop = System.getProperties();
prop.put("mail.smtp.auth", "true");
Copy link
Member

Choose a reason for hiding this comment

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

Is this mandatory? I noticed the following instruction from the javadoc

To use SMTP authentication you'll need to set the mail.smtp.auth property (see below) or provide the SMTP Transport with a username and password when connecting to the SMTP server.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I just remove this line. The test is fine. Please take a look.

@nisiyong nisiyong force-pushed the support-email-config branch from d617268 to d25df08 Compare December 10, 2020 12:22
kezhenxu94
kezhenxu94 previously approved these changes Dec 11, 2020
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

one nit, otherwise looks good to me

pom.xml Outdated Show resolved Hide resolved
Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

LGTM

@nobodyiam nobodyiam merged commit f8683a2 into apolloconfig:master Dec 12, 2020
@nisiyong nisiyong deleted the support-email-config branch December 12, 2020 03:01
@nobodyiam nobodyiam added this to the 1.8.0 milestone Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants