Skip to content

Commit

Permalink
Simplify SmtpClient .cctor
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Jan 16, 2024
1 parent fd304da commit e76ef93
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions MailKit/Net/Smtp/SmtpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal static string GetSafeHostName (string hostName)

try {
return idn.GetAscii (hostName);
} catch (ArgumentException) {
} catch {
// This can happen if the hostName contains illegal unicode characters.
var ascii = new StringBuilder ();
for (int i = 0; i < hostName.Length; i++) {
Expand All @@ -118,13 +118,7 @@ internal static string GetSafeHostName (string hostName)

static SmtpClient ()
{
string hostName;

try {
hostName = GetSafeHostName (IPGlobalProperties.GetIPGlobalProperties ().HostName);
} catch {
hostName = null;
}
var hostName = GetSafeHostName (IPGlobalProperties.GetIPGlobalProperties ().HostName);

DefaultLocalDomain = hostName ?? "localhost";
}
Expand Down

0 comments on commit e76ef93

Please sign in to comment.