Presumption: Developer has basic knowledge of Orchard Core CMS.
Get basics of OrchardCore CMS. Click Here
You can find installation steps. Click Here
Download latest OrchardCore CMS from below URL
https://github.com/OrchardCMS/OrchardCore.
Configuring Orchard to send email is done by enabling the Email Messaging module and adding the proper email settings.
1. Login as a host user.
2. In Admin Panel, Go to Modules.
3. Enable Email Messaging Module.
4. This will add SMTP menu in Settings.
5. Provide appropriate sender email address and Delivery Method. Delivery Method can be
1. Network
2. pecified pickup directory
6. Provide SMTP settings for sending actual email via “Network” Or provide directory location for “Specified pickup directory”.
Test Email Settings.
1. Click on Test Settings.
2. Provide all information. And Send.
You will receive an email in specified provider.
Create email template and send email via user action.
Below steps will show how to create email template and use it to send an email on user action.
1. Create MyDemoEmail.cshtml in Views folder.
2. Create MyDemoEmailViewModel.cs in Models folder. Implement ShapeViewModel interface.
using OrchardCore.DisplayManagement.Views;
namespace OrchardCore.Users.ViewModels
{
public class MyDemoEmailViewModel : ShapeViewModel
{
public MyDemoEmailViewModel()
{
Metadata.Type = "MyDemoEmail";
}
public IUser User { get; set; }
}
}
3. Call below function on user action from controller.
private async Task SendDemoEmail(User user)
{
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("Index", "Home");
await SendEmailAsync(user.Email, T["Welcome!"], new MyDemoEmailViewModel() { User = user});
return callbackUrl;
}
4. Add below code to the constructor of your startup class
TemplateContext.GlobalMemberAccessStrategy.Register<MyDemoEmailViewModel>();