ive been trying for a week to get email sending to work with no luck. my test was on sending email for password reset
appsettings.json
settings provider of my app
and DomainModule of my app
ive been looking at official documentation but unfortunately for me its to vague and not detailed.
after i click on forgot password, type email and click send this error pops up
FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
System.Convert.FromBase64CharPtr(Char* inputPtr, int inputLength)
System.Convert.FromBase64String(string s)
Volo.Abp.Security.Encryption.StringEncryptionService.Decrypt(string cipherText, string passPhrase, byte[] salt)
Volo.Abp.Settings.SettingEncryptionService.Decrypt(SettingDefinition settingDefinition, string encryptedValue)
Volo.Abp.Settings.SettingProvider.GetOrNullAsync(string name)
Volo.Abp.Emailing.EmailSenderConfiguration.GetNotEmptySettingValueAsync(string name)
Volo.Abp.Emailing.Smtp.SmtpEmailSender.BuildClientAsync()
Volo.Abp.Emailing.Smtp.SmtpEmailSender.SendEmailAsync(MailMessage mail)
Volo.Abp.Emailing.EmailSenderBase.SendAsync(MailMessage mail, bool normalize)
Volo.Abp.Emailing.EmailSenderBase.SendAsync(string to, string subject, string body, bool isBodyHtml)
Volo.Abp.Account.Emailing.AccountEmailer.SendPasswordResetLinkAsync(IdentityUser user, string resetToken, string appName, string returnUrl, string returnUrlHash)
Volo.Abp.Account.AccountAppService.SendPasswordResetCodeAsync(SendPasswordResetCodeDto input)
you have to store the encrypted version of your password in the appsettings.json
simply use this snippet somewhere in your app
public class EmailSettingProvider : SettingDefinitionProvider
{
private readonly ISettingEncryptionService encryptionService;
public EmailSettingProvider(ISettingEncryptionService encryptionService)
{
this.encryptionService = encryptionService;
}
public override void Define(ISettingDefinitionContext context)
{
var passSetting = context.GetOrNull("Abp.Mailing.Smtp.Password");
if(passSetting!=null)
{
string debug = encryptionService.Encrypt(passSetting,"1q2w3e$R");
}
}
}
set a break point and copy the value in the debug
variable to the appsettings.json file and that's all the configuration you need.