mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2025-03-18 18:14:02 +00:00
Add option for smtp without encryption
This commit is contained in:
parent
100a7e11dc
commit
05e0f1e270
@ -12,7 +12,7 @@ from django.db.models import Max
|
||||
from django.utils import timezone
|
||||
|
||||
from user_manager.models import UserAcl
|
||||
from vpn_invite.models import PeerInvite, InviteSettings
|
||||
from vpn_invite.models import InviteSettings, PeerInvite
|
||||
from wireguard.models import Peer, WireGuardInstance
|
||||
from wireguard_tools.models import EmailSettings
|
||||
|
||||
@ -197,11 +197,13 @@ def send_email(destination, subject, body):
|
||||
|
||||
if email_settings.smtp_encryption.lower() == 'ssl':
|
||||
server = smtplib.SMTP_SSL(email_settings.smtp_host, email_settings.smtp_port)
|
||||
elif email_settings.smtp_encryption.lower() in ['none', 'noauth']:
|
||||
server = smtplib.SMTP(email_settings.smtp_host, email_settings.smtp_port)
|
||||
else:
|
||||
server = smtplib.SMTP(email_settings.smtp_host, email_settings.smtp_port)
|
||||
server.starttls()
|
||||
|
||||
if email_settings.smtp_username and email_settings.smtp_password:
|
||||
if email_settings.smtp_username and email_settings.smtp_password and email_settings.smtp_encryption.lower() != 'noauth':
|
||||
server.login(email_settings.smtp_username, email_settings.smtp_password)
|
||||
|
||||
server.sendmail(email_settings.smtp_from_address, destination, msg.as_string())
|
||||
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.5 on 2025-03-13 00:07
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wireguard_tools', '0002_emailsettings_enabled'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='emailsettings',
|
||||
name='smtp_encryption',
|
||||
field=models.CharField(choices=[('ssl', 'SSL'), ('tls', 'TLS'), ('none', 'None (Insecure)'), ('noauth', 'No authentication (Insecure)')], default='tls', max_length=6),
|
||||
),
|
||||
]
|
@ -1,6 +1,7 @@
|
||||
from django.db import models
|
||||
import uuid
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class EmailSettings(models.Model):
|
||||
name = models.CharField(default='email_settings', max_length=20, unique=True)
|
||||
@ -8,7 +9,7 @@ class EmailSettings(models.Model):
|
||||
smtp_password = models.CharField(max_length=100, blank=True, null=True)
|
||||
smtp_host = models.CharField(max_length=100, blank=True, null=True)
|
||||
smtp_port = models.IntegerField(default=587)
|
||||
smtp_encryption = models.CharField(default='tls', choices=(('ssl', 'SSL'), ('tls', 'TLS')), max_length=3)
|
||||
smtp_encryption = models.CharField(default='tls', choices=(('ssl', 'SSL'), ('tls', 'TLS'), ('none', 'None (Insecure)'), ('noauth', 'No authentication (Insecure)')), max_length=6)
|
||||
smtp_from_address = models.EmailField(blank=True, null=True)
|
||||
enabled = models.BooleanField(default=True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user