Is this right ?? can you please check below Note I cannot define _abpMailKitConfiguration but the error appear System.Net.Sockets.SocketException: 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.16.2.119:25'
public class DefaultMailKitSmtpBuilder : IMailKitSmtpBuilder, ITransientDependency
{
private readonly ISmtpEmailSenderConfiguration _smtpEmailSenderConfiguration;
//private readonly IAbpMailKitConfiguration _abpMailKitConfiguration;
public DefaultMailKitSmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration)
{
_smtpEmailSenderConfiguration = smtpEmailSenderConfiguration;
}
public virtual SmtpClient Build()
{
var client = new SmtpClient();
try
{
ConfigureClient(client);
return client;
}
catch
{
client.Dispose();
throw;
}
}
protected virtual void ConfigureClient(SmtpClient client)
{
client.Connect(
_smtpEmailSenderConfiguration.Host,
_smtpEmailSenderConfiguration.Port,
GetSecureSocketOption()
);
if (_smtpEmailSenderConfiguration.UseDefaultCredentials)
{
return;
}
client.Authenticate(
_smtpEmailSenderConfiguration.UserName,
_smtpEmailSenderConfiguration.Password
);
}
protected virtual SecureSocketOptions GetSecureSocketOption()
{
return _smtpEmailSenderConfiguration.EnableSsl
? SecureSocketOptions.SslOnConnect
: SecureSocketOptions.StartTlsWhenAvailable;
}
}
//if (DebugHelper.IsDebug)
//{
// //Disabling email sending in debug mode
// Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);
//}
Configuration.ReplaceService(typeof(IEmailSenderConfiguration), () =>
{
Configuration.IocManager.IocContainer.Register(
Component.For<IEmailSenderConfiguration, ISmtpEmailSenderConfiguration>()
.ImplementedBy<BarznWebSmtpEmailSenderConfiguration>()
.LifestyleTransient()
);
});
Configuration.ReplaceService<IMailKitSmtpBuilder, DefaultMailKitSmtpBuilder>(DependencyLifeStyle.Transient);
<cite>maliming: </cite> You can refer to this reply to solve. [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3547#issuecomment-400181114])
Error MailKit.Security.AuthenticationException: 'AuthenticationInvalidCredentials: 5.7.3
Authentication unsuccessful' /// Define new class public class MyMailKitSmtpBuilder : DefaultMailKitSmtpBuilder { public MyMailKitSmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration) : base(smtpEmailSenderConfiguration) { }
protected override void ConfigureClient(SmtpClient client)
{
client.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
base.ConfigureClient(client);
}
}
I implement in the PreInitialize below code /////////PreInitialize// Configuration.ReplaceService(typeof(IEmailSenderConfiguration), () => { Configuration.IocManager.IocContainer.Register( Component.For<IEmailSenderConfiguration, ISmtpEmailSenderConfiguration>() .ImplementedBy<BarznWebSmtpEmailSenderConfiguration>() .LifestyleTransient() ); }); Configuration.ReplaceService<IMailKitSmtpBuilder, MyMailKitSmtpBuilder>(DependencyLifeStyle.Transient); //////////////////////////////////////////////////////////////
<cite>maliming: </cite> Please check if the currently accessed user is granted permission.
Can you please check that I sent screenshot to you
<cite>alper: </cite> wouv! same time @maliming :)
in same time I call it and working now thanks
Can we Add new column to Model in the Core Layer in the Code First , using injection assembly.