Compare commits
2 Commits
6c4b876191
...
feb4a67291
| Author | SHA1 | Date | |
|---|---|---|---|
|
feb4a67291
|
|||
|
f0b924ea56
|
@@ -76,11 +76,10 @@ class EmailService:
|
||||
smtp_host = self.config["smtp_host"]
|
||||
smtp_port = self.config["smtp_port"]
|
||||
|
||||
server = smtplib.SMTP(smtp_host, smtp_port)
|
||||
with smtplib.SMTP(smtp_host, smtp_port) as server:
|
||||
if self.config.get("smtp_starttls", False):
|
||||
server.starttls()
|
||||
|
||||
try:
|
||||
if self.config.get("smtp_user"):
|
||||
server.login(
|
||||
self.config["smtp_user"],
|
||||
@@ -89,8 +88,6 @@ class EmailService:
|
||||
server.sendmail(msg["From"], [to], msg.as_string())
|
||||
logging.info(f"Email sent: to={to} subject={subject}")
|
||||
return True
|
||||
finally:
|
||||
server.quit()
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Email send failed: to={to} error={e}")
|
||||
|
||||
@@ -9,6 +9,7 @@ from peewee import (
|
||||
CharField,
|
||||
DateTimeField,
|
||||
DoesNotExist,
|
||||
fn,
|
||||
ForeignKeyField,
|
||||
IntegerField,
|
||||
Model,
|
||||
@@ -297,7 +298,7 @@ def get_hostname_for_user(hostname: str, user: User):
|
||||
Raises:
|
||||
DoesNotExist: If hostname not found or not owned by user.
|
||||
"""
|
||||
fqdn = Hostname.hostname + '.' + Hostname.zone
|
||||
fqdn = fn.Concat(Hostname.hostname, '.', Hostname.zone)
|
||||
return Hostname.get((fqdn == hostname) & (Hostname.user == user))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user