Skip to content

Commit

Permalink
增加邮件发送功能
Browse files Browse the repository at this point in the history
增加邮件发送功能
  • Loading branch information
layman44 committed Nov 24, 2017
1 parent c8283cd commit 8977753
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 2 deletions.
11 changes: 11 additions & 0 deletions 3.1.2/Birthday.Mail/Birthday.Mail.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abp.MailKit" Version="3.2.4" />
</ItemGroup>

</Project>
51 changes: 51 additions & 0 deletions 3.1.2/Birthday.Mail/BirthdayEmailSettingProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Abp.Configuration;
using Abp.Localization;
using Abp.Net.Mail;
using System;
using System.Collections.Generic;
using System.Text;

namespace Birthday.Mail
{
public class BirthdayEmailSettingProvider : SettingProvider
{
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
{
return new[]
{
new SettingDefinition(EmailSettingNames.Smtp.Host, "smtp.qq.com", L("SmtpHost"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.Smtp.Port, "465", L("SmtpPort"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.Smtp.UserName, "[email protected]", L("Username"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.Smtp.Password, "daulgejvjyzbcabf", L("Password"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.Smtp.Domain, "smtp.qq.com", L("DomainName"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.Smtp.EnableSsl, "true", L("UseSSL"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.Smtp.UseDefaultCredentials, "true", L("UseDefaultCredentials"),
scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.DefaultFromAddress, "MyDefaultFromAddress",
L("DefaultFromSenderEmailAddress"), scopes: SettingScopes.Application | SettingScopes.Tenant),

new SettingDefinition(EmailSettingNames.DefaultFromDisplayName, "MyDefaultFromDisplayName",
L("DefaultFromSenderDisplayName"), scopes: SettingScopes.Application | SettingScopes.Tenant)
};
}

private static ILocalizableString L(string name)
{
return new LocalizableString(name, BirthdayConsts.LocalizationSourceName);
}

}
}
22 changes: 22 additions & 0 deletions 3.1.2/Birthday.Mail/BirthdayMailModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Abp.MailKit;
using Abp.Modules;
using Abp.Reflection.Extensions;
using System;
using System.Collections.Generic;
using System.Text;

namespace Birthday.Mail
{
[DependsOn(typeof(AbpMailKitModule))]
public class BirthdayMailModule : AbpModule
{
public override void PreInitialize()
{
Configuration.Settings.Providers.Add<BirthdayEmailSettingProvider>();
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(BirthdayMailModule).GetAssembly());
}
}
}
34 changes: 34 additions & 0 deletions 3.1.2/Birthday.Mail/MailSendManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Abp.Configuration;
using Abp.Domain.Services;
using Abp.Net.Mail;
using System;
using System.Collections.Generic;
using System.Text;

namespace Birthday.Mail
{
public class MailSendManager : IDomainService
{
private readonly IEmailSender _emailSender;

private readonly ISettingManager _settingManager;

public MailSendManager(IEmailSender emailSender, ISettingManager settingManager)
{
_emailSender = emailSender;
_settingManager = settingManager;
}

public void SendMail()
{
_emailSender.Send(
from: _settingManager.GetSettingValue(EmailSettingNames.DefaultFromAddress),
to: "",
subject: "",
body: "",
isBodyHtml: true
);
}

}
}
30 changes: 30 additions & 0 deletions 3.1.2/Birthday.Mail/TaskManger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Abp.Configuration;
using Abp.Domain.Services;
using Abp.Net.Mail;

namespace Birthday.Mail
{
public class TaskManger : IDomainService
{
private readonly IEmailSender _emailSender;

private readonly ISettingManager _settingManager;

public TaskManger(IEmailSender emailSender, ISettingManager settingManager)
{
_emailSender = emailSender;
_settingManager = settingManager;
}

public void Assgin()
{
_emailSender.Send(
from: _settingManager.GetSettingValue(EmailSettingNames.DefaultFromAddress),
to: "",
subject: "",
body: "",
isBodyHtml: true
);
}
}
}
12 changes: 11 additions & 1 deletion 3.1.2/Birthday.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}"
EndProject
Expand All @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Birthday.Tests", "test\Birt
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Birthday.Web.Tests", "test\Birthday.Web.Tests\Birthday.Web.Tests.csproj", "{5D441612-29CA-4DAD-9945-B9DE11CE026C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Birthday.Mail", "Birthday.Mail\Birthday.Mail.csproj", "{F29337A3-A5CE-4C33-92CB-C40977B1B50D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -49,6 +51,10 @@ Global
{5D441612-29CA-4DAD-9945-B9DE11CE026C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D441612-29CA-4DAD-9945-B9DE11CE026C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D441612-29CA-4DAD-9945-B9DE11CE026C}.Release|Any CPU.Build.0 = Release|Any CPU
{F29337A3-A5CE-4C33-92CB-C40977B1B50D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F29337A3-A5CE-4C33-92CB-C40977B1B50D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F29337A3-A5CE-4C33-92CB-C40977B1B50D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F29337A3-A5CE-4C33-92CB-C40977B1B50D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -60,5 +66,9 @@ Global
{DC780BC4-4EAC-4C63-9052-6F3169A59FA4} = {AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}
{0D4C5D00-C144-4213-A007-4B8944113AB1} = {F10AA149-2626-486E-85BB-9CD5365F3016}
{5D441612-29CA-4DAD-9945-B9DE11CE026C} = {F10AA149-2626-486E-85BB-9CD5365F3016}
{F29337A3-A5CE-4C33-92CB-C40977B1B50D} = {AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D91FD598-A786-4CC8-80FE-271C1C1197C6}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class CreatePersonInput
public string RelationShip { get; set; }

[Required]
[DataType(DataType.Date)]
public DateTime Birthday { get; set; }

[Required]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class EditPersonInput: Entity<Guid>, IHasModificationTime, ICustomValidat
public string RelationShip { get; set; }

[Required]
[DataType(DataType.Date)]
public DateTime Birthday { get; set; }

[Required]
Expand Down
15 changes: 15 additions & 0 deletions 3.1.2/src/Birthday.Core/EmailSendConfig/EmailSendConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using System;
using System.Collections.Generic;
using System.Text;

namespace Birthday.EmailSendConfig
{
public class EmailSendConfig : Entity<Guid>, IHasCreationTime, IHasModificationTime
{
public DateTime CreationTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public DateTime? LastModificationTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
}
1 change: 1 addition & 0 deletions 3.1.2/src/Birthday.Core/Persons/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Person : Entity<Guid>, IHasCreationTime,IHasModificationTime
public string RelationShip { get; set; }

[Required]
[DataType(DataType.Date)]
public DateTime Birthday { get; set; }

public string PhoneNum { get; set; }
Expand Down
1 change: 1 addition & 0 deletions 3.1.2/src/Birthday.Web/wwwroot/js/views/person/edit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

0 comments on commit 8977753

Please sign in to comment.