add support for smtp clients that requires no authentication.
This commit is contained in:
@@ -146,7 +146,11 @@ namespace CarCareTracker.Helper
|
|||||||
using (var client = new SmtpClient())
|
using (var client = new SmtpClient())
|
||||||
{
|
{
|
||||||
client.Connect(server, mailConfig.Port, MailKit.Security.SecureSocketOptions.Auto);
|
client.Connect(server, mailConfig.Port, MailKit.Security.SecureSocketOptions.Auto);
|
||||||
client.Authenticate(mailConfig.Username, mailConfig.Password);
|
//perform authentication if either username or password is provided.
|
||||||
|
//do not perform authentication if neither are provided.
|
||||||
|
if (!string.IsNullOrWhiteSpace(mailConfig.Username) || !string.IsNullOrWhiteSpace(mailConfig.Password)) {
|
||||||
|
client.Authenticate(mailConfig.Username, mailConfig.Password);
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.Send(message);
|
client.Send(message);
|
||||||
|
|||||||
Reference in New Issue
Block a user