/// <summary>Returns certain <see cref="IEmailClient"/> class instance.</summary> /// <param name="credentials">An instance of <see cref="DTO.Credentials"/> user credentials.</param> /// <returns>Certain <see cref="IEmailClient"/> class instance.</returns> protected IEmailClient GetCertainEmailClient(DTO.Credentials credentials) { if (UserConnection.GetIsFeatureEnabled("EmailIntegrationV2")) { return(ClassFactory.Get <IEmailClient>( new ConstructorArgument("userConnection", UserConnection), new ConstructorArgument("emailCredentials", credentials) )); } return(null); }
/// <summary> /// Convert <see cref="DTO.Credentials"/> to <see cref="MailCredentials"/> instance. /// </summary> /// <param name="credentials"><see cref="DTO.Credentials"/> instance.</param> /// <returns><see cref="MailCredentials"/> credentials.</returns> private MailCredentials ConvertToMailCredentials(DTO.Credentials credentials) { return(new MailCredentials { Host = credentials.ServiceUrl, Port = credentials.Port, UserName = credentials.UserName, UserPassword = credentials.Password, UseSsl = credentials.UseSsl, UseOAuth = credentials.UseOAuth, SenderEmailAddress = credentials.SenderEmailAddress }); }
/// <summary> /// <see cref="EmailClient"/> ctor. /// </summary> /// <param name="userConnection">An instance of the user connection.</param> /// <param name="credentials">Short email connection credentials.</param> public EmailClient(UserConnection userConnection, Mail.Credentials credentials) : this(userConnection) { var mailServer = GetMailServer(credentials.ServerId); _credentials = new Credentials { UserName = credentials.UserName, Password = credentials.UserPassword, UseOAuth = credentials.UseOAuth, ServiceUrl = mailServer.ServerAddress, ServerTypeId = mailServer.TypeId, Port = mailServer.Port, UseSsl = mailServer.UseSsl }; }
/// <summary> /// Returns an email client object that implements interface <see cref="IEmailClient"/> /// according to specified connection parameters.</summary> /// <param name="credentials">Connection credentials.</param> /// <returns>Instance of <see cref="IEmailClient"/>.</returns> public virtual IEmailClient CreateEmailClient(DTO.Credentials credentials) { return(GetCertainEmailClient(credentials) ?? GetSmtpClient(credentials)); }
/// <summary> /// <see cref="EmailClient"/> ctor. /// </summary> /// <param name="userConnection">An instance of the user connection.</param> /// <param name="emailCredentials">Full email connection credentials.</param> public EmailClient(UserConnection userConnection, Credentials emailCredentials) : this(userConnection) { _credentials = emailCredentials; }