Ejemplo n.º 1
0
        /// <param name="client">The <see cref="IMailClient"/> instance.</param>
        /// <param name="host">The server host.</param>
        /// <param name="port">The server port.</param>
        /// <param name="useSsl">Indicates whether to use ssl.</param>
        /// <inheritdoc cref="IMailClient.Authenticate(Uri, string, string, Encoding)"/>
        public static void Authenticate(this IMailClient client, string host, int port, bool useSsl, string userName, string password, Encoding?encoding = null)
        {
            _ = client ?? throw new ArgumentNullException(nameof(client));
            _ = host ?? throw new ArgumentNullException(nameof(host));
            _ = userName ?? throw new ArgumentNullException(nameof(userName));
            _ = password ?? throw new ArgumentNullException(nameof(password));

            Uri uri = new UriBuilder(useSsl ? $"{client.Protocol}s" : client.Protocol, host, port).Uri;

            client.Authenticate(uri, userName, password, encoding);
        }