Skip to content

Commit

Permalink
Reversed AuthenticationNotRequired to AuthenticationRequired
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisM000 committed Oct 4, 2024
1 parent cab7c14 commit c5ba5c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Previous classification is not required if changes are simple or all belong to t

### Minor Changes

- Added `AuthenticationNotRequired` property to `SmtpClientOptions.cs`, which can be set to `true` when the SMTP server does not require authentication (i.e., no username/password is needed).
- Added the `AuthenticationRequired` property to `SmtpClientOptions.cs`, which is set to `true` by default. This indicates that authentication is required to connect to the SMTP server. If set to `false`, the server does not require authentication, meaning no username or password is needed for the connection.

## [8.1.8]

### Breaking Changes
Expand Down
15 changes: 9 additions & 6 deletions src/Encamina.Enmarcha.Email.Abstractions/SmtpClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ public class SmtpClientOptions : INameable
private string? name = null;

/// <summary>
/// Gets or sets a value indicating whether authentication is not required to connect to the SMTP service.
/// Gets a value indicating whether authentication is required to connect to the SMTP service.
/// </summary>
public bool AuthenticationNotRequired { get; set; }
/// <remarks>
/// The default value is <see langword="true"/>. Set this to <see langword="false"/> if the SMTP service does not require authentication.
/// </remarks>
public bool AuthenticationRequired { get; init; } = true;

/// <summary>
/// Gets or sets the host name of the SMTP service.
Expand All @@ -34,9 +37,9 @@ public string Name

/// <summary>
/// Gets or sets the password credential required to connect to the SMTP service.
/// <para>This property is only required if <see cref="AuthenticationNotRequired"/> is set to <see langword="false"/>.</para>
/// <para>This property is only required if <see cref="AuthenticationRequired"/> is set to <see langword="false"/>.</para>
/// </summary>
[RequiredIf(nameof(AuthenticationNotRequired), conditionalValue: false, allowEmpty: false)]
[RequiredIf(nameof(AuthenticationRequired), conditionalValue: true, allowEmpty: false)]
public string? Password { get; set; }

/// <summary>
Expand All @@ -55,9 +58,9 @@ public string Name

/// <summary>
/// Gets or sets the user credential required to connect to the SMTP service.
/// <para>This property is only required if <see cref="AuthenticationNotRequired"/> is set to <see langword="false"/>.</para>
/// <para>This property is only required if <see cref="AuthenticationRequired"/> is set to <see langword="false"/>.</para>
/// </summary>
[RequiredIf(nameof(AuthenticationNotRequired), conditionalValue: false, allowEmpty: false)]
[RequiredIf(nameof(AuthenticationRequired), conditionalValue: true, allowEmpty: false)]
public string? User { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Encamina.Enmarcha.Email.MailKit/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task SendAsync(CancellationToken cancellationToken)

await smtpClient.ConnectAsync(SmtpClientOptions.Host, SmtpClientOptions.Port, SmtpClientOptions.UseSSL, cancellationToken);

if (!SmtpClientOptions.AuthenticationNotRequired)
if (SmtpClientOptions.AuthenticationRequired)
{
await smtpClient.AuthenticateAsync(SmtpClientOptions.User, SmtpClientOptions.Password, cancellationToken);
}
Expand Down

0 comments on commit c5ba5c1

Please sign in to comment.