/// <summary> /// Connects to the server. /// </summary> /// <returns>True for successful connection. False otherwise.</returns> private async Task <bool> ConnectAsync() { try { if (IsConnected) { Socket.Dispose(); IsConnected = false; } Socket = new SmtpSocket(Server, Port, SSL); SmtpResponse response = await Socket.EstablishConnection(); if (response.ContainsStatus(SmtpCode.ServiceReady)) { IsConnected = true; return(true); } } catch { return(false); } return(false); }
/// <summary> /// Connects to the server. /// </summary> /// <returns>True for successful connection. False otherwise.</returns> public async Task <bool> Connect() { try { if (IsConnected) { Socket.Close(); IsConnected = false; } Socket = new SmtpSocket(Server, Port, SSL, Username, Password); SmtpResponse response = await Socket.EstablishConnection(); if (response.Contains(SmtpCode.ServiceReady)) { IsConnected = true; return(true); } } catch { return(false); } return(false); }
/// <summary> /// Connects to the server. /// </summary> /// <returns>True for successful connection. False otherwise.</returns> public async Task<bool> Connect() { try { if (IsConnected) { Socket.Close(); IsConnected = false; } Socket = new SmtpSocket(Server, Port, SSL, Username, Password); SmtpResponse response = await Socket.EstablishConnection(); if (response.Contains(SmtpCode.ServiceReady)) { IsConnected = true; return true; } } catch { return false; } return false; }