Good afternoon! I need some help to send emails through ABP
Here is what I did so far:
Created this class
class EmailSettingProvider : SettingProvider
{
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
{
return new[]
{
new SettingDefinition(EmailSettingNames.Smtp.Host, "smtp.gmail.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, "****@gmail.com", L("Username"), scopes: SettingScopes.Application | SettingScopes.Tenant),
new SettingDefinition(EmailSettingNames.Smtp.Password, "*****", L("Password"), scopes: SettingScopes.Application | SettingScopes.Tenant),
new SettingDefinition(EmailSettingNames.Smtp.Domain, "gmail.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, "****@gmail.com", L("DefaultFromSenderEmailAddress"), scopes: SettingScopes.Application | SettingScopes.Tenant),
new SettingDefinition(EmailSettingNames.DefaultFromDisplayName, "My Name", L("DefaultFromSenderDisplayName"), scopes: SettingScopes.Application | SettingScopes.Tenant)
};
}
private static LocalizableString L(string name)
{
return new LocalizableString(name, AbpConsts.LocalizationSourceName);
}
}
On my Application Module
public override void PreInitialize()
{
Configuration.Settings.Providers.Add<EmailSettingProvider>();
}
Created an App Service
public class EmailAppService : NHiveAppServiceBase, IEmailAppService
{
private readonly ISmtpEmailSender _smtpEmailSender;
public EmailAppService(
ISmtpEmailSender smtpEmailSender)
{
_smtpEmailSender = smtpEmailSender;
}
public async Task SendTestEmail()
{
_smtpEmailSender.Send("[email protected]", "[email protected]", "test", false);
}
}
Did I do it correctly? As I understood from my google searches, SmtpEmailSender gets the settings automatically from the PreInitialize method. Is that correct?
It failed to send the e-mail, though.
Thanks in advance,
Thank you very much !
Thanks for the reply guys!
Could somebody explain me the conceptual difference between a Store and a Manager?
I would like to implement some Custom Maps. Where would be the perfect place to do so? In my application module?
How should I implement removerange using the defaul IRepository?
Thanks in advance.
I've been trying to create some modules in my solution. At the moment I have 2 core modules (inside a single project), 2 application modules (inside a single project) and one data module. I also have 2 web applications (alongside 2 apis) for different purposes. Whenever I try to run any of these web applications, I get the following error:
Component AbpCompanyName.AbpProjectName could not be registered. There is already a component with that name. Did you want to modify the existing component instead? If not, make sure you specify a unique name.
Should I separate my modules in different projects to make it work? Or should I unify my modules into one?
Thanks!
When you setup your partial view for the top bar (for example), you get a object of type MainMenu that you could manipulate at your own will. Otherwise, you could edit the setnavigation method from NavigationProvider to include some extra logic.
You just have to Add Items at your own will!
Maybe I should change my question: can I work with 2 different deploys sharing one single entity framework? Or should multi-tenant be always single-deploy?
First of all, I would like to Congratulate Halil for his amazing job. I am amazed and in love with ABP! Thanks for your effort put on this.
I have a question regarding ABP organization. I am thinking about suggesting my fellow coworkers to migrate to ABP so we can develop all our applications on top of it. My question is: if I wanna allow each tenant to develop their own application, how should the projects be organized?
Considering the projects inside the default solution: Application, Core, EntityFramework, Web and WebApi, how should we distribute the application development? We should centralize all development of inside the Core and Application folders and have a separate Web and Web Api for each application?
Or should we distribute the Application and Core as well? Each team (under a tenant) has its own Applicaiton and Core that depens on the main module (such as asp.net zero)?
Thanks in advance!