This is the settings:
AddSettingIfNotExists(EmailSettingNames.DefaultFromAddress, "abc@xyz.tech");
AddSettingIfNotExists(EmailSettingNames.DefaultFromDisplayName, "abc.tech Emailservice");
AddSettingIfNotExists(EmailSettingNames.Smtp.UserName, "abc@xyz.tech");
AddSettingIfNotExists(EmailSettingNames.Smtp.Domain, "abc.tech");
AddSettingIfNotExists(EmailSettingNames.Smtp.EnableSsl,"false");
AddSettingIfNotExists(EmailSettingNames.Smtp.Host, "webmail.abc.tech");
AddSettingIfNotExists(EmailSettingNames.Smtp.Port, "25");
AddSettingIfNotExists(EmailSettingNames.Smtp.Password, "gdfdgd");
AddSettingIfNotExists(EmailSettingNames.Smtp.UseDefaultCredentials, "false");
This is the email sending code:
// See "Update"
I am getting this exception:
Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server
Update
public class UserAppService // ...
{
private readonly UserManager _userManager;
private readonly RoleManager _roleManager;
IRepository<User, long> _rep;
private readonly IRepository<Role> _roleRepository;
private readonly IPasswordHasher<User> _passwordHasher;
public readonly IEmailSender _emailSender;
public UserAppService(
IRepository<User, long> repository,
UserManager userManager,
RoleManager roleManager,
IRepository<Role> roleRepository,
IPasswordHasher<User> passwordHasher, IEmailSender em)
: base(repository)
{
_rep = repository;
_userManager = userManager;
_roleManager = roleManager;
_roleRepository = roleRepository;
_passwordHasher = passwordHasher;
_emailSender = em;
}
[AbpAllowAnonymous]
public override async Task<UserDto> Create(CreateUserDto input)
{
// CheckCreatePermission();
var user = ObjectMapper.Map<User>(input);
user.TenantId = AbpSession.TenantId;
user.Password = _passwordHasher.HashPassword(user, input.Password);
user.IsEmailConfirmed = false;
CheckErrors(await _userManager.CreateAsync(user));
if (input.RoleNames != null)
{
CheckErrors(await _userManager.SetRoles(user, input.RoleNames));
}
CurrentUnitOfWork.SaveChanges();
try
{
await _emailSender.SendAsync("test@gmail.com", "sdfs", "sdfsd", false);
}
catch (Exception ex)
{
}
return MapToEntityDto(user);
}
}