mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-24 23:02:44 +00:00
New: Require Encryption option for email
Fixes #1908 (cherry picked from commit e704ee617f379ff61fb1bf9fb4044d6b4eb12814)
This commit is contained in:
parent
a943636905
commit
419ec2bdb9
2 changed files with 20 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using FluentValidation.Results;
|
||||
using MailKit.Net.Smtp;
|
||||
using MailKit.Security;
|
||||
using MimeKit;
|
||||
using NLog;
|
||||
|
||||
|
@ -51,7 +52,21 @@ private void Send(MimeMessage email, EmailSettings settings)
|
|||
{
|
||||
using (var client = new SmtpClient())
|
||||
{
|
||||
client.Connect(settings.Server, settings.Port);
|
||||
var serverOption = SecureSocketOptions.Auto;
|
||||
|
||||
if (settings.RequireEncryption)
|
||||
{
|
||||
if (settings.Port == 465)
|
||||
{
|
||||
serverOption = SecureSocketOptions.SslOnConnect;
|
||||
}
|
||||
else
|
||||
{
|
||||
serverOption = SecureSocketOptions.StartTls;
|
||||
}
|
||||
}
|
||||
|
||||
client.Connect(settings.Server, settings.Port, serverOption);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(settings.Username))
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ public class EmailSettings : IProviderConfig
|
|||
|
||||
public EmailSettings()
|
||||
{
|
||||
Port = 25;
|
||||
Port = 587;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "Server", HelpText = "Hostname or IP of Email server")]
|
||||
|
@ -31,6 +31,9 @@ public EmailSettings()
|
|||
[FieldDefinition(1, Label = "Port")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Require Encryption", HelpText = "Require SSL (Port 465 only) or StartTLS (any other port)", Type = FieldType.Checkbox)]
|
||||
public bool RequireEncryption { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Username", Privacy = PrivacyLevel.UserName)]
|
||||
public string Username { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue