This commit is contained in:
parent
6d8743e183
commit
f6d0916dec
4 changed files with 69 additions and 19 deletions
|
@ -31,7 +31,7 @@ class MailSettings(BaseSettings):
|
|||
"""\
|
||||
{text}
|
||||
---
|
||||
From: {from}
|
||||
From: {from} {fromName}
|
||||
Sent: {sentStamp:%c}
|
||||
Received: {receivedStamp:%c}
|
||||
Sim: {sim}
|
||||
|
@ -45,7 +45,8 @@ class Settings(BaseSettings):
|
|||
|
||||
|
||||
class SmsAlert(BaseModel):
|
||||
from_: str = Field(alias="from")
|
||||
from_: str = Field(alias="from") # "from" is reserved word in Python, use an alias
|
||||
fromName: str = ""
|
||||
text: str
|
||||
sentStamp: datetime
|
||||
receivedStamp: datetime
|
||||
|
@ -61,7 +62,7 @@ def send_mail(smsAlert: SmsAlert):
|
|||
msg["Subject"] = f"SMS from {smsAlert.from_}"
|
||||
msg["From"] = settings.mail.sender
|
||||
msg["To"] = settings.mail.to
|
||||
fmt = dict(smsAlert)
|
||||
fmt = dict(smsAlert) # Make a dict for sms
|
||||
fmt["from"] = fmt.pop("from_")
|
||||
msg.set_content(settings.mail.template.format_map(fmt))
|
||||
return send(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue