Skip to content

Commit

Permalink
fix: email from address formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRomaa committed Apr 7, 2024
1 parent dfece08 commit 2490cc2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ EMAIL_PORT=
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_USE_TLS=
EMAIL_ADDRESS=

VATSIM_CONNECT_CLIENT_ID=
VATSIM_CONNECT_CLIENT_SECRET=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.3 on 2024-04-07 02:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mailer', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='email',
name='bcc_email',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='email',
name='cc_email',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='email',
name='from_email',
field=models.EmailField(max_length=254),
),
]
9 changes: 4 additions & 5 deletions apps/mailer/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import traceback
from smtplib import SMTPException
from typing import Any
Expand Down Expand Up @@ -44,10 +43,10 @@ class Email(models.Model):
subject = models.CharField(max_length=255)
html_body = models.TextField()
text_body = models.TextField()
from_email = models.EmailField(null=True)
from_email = models.EmailField()
to_email = models.TextField()
cc_email = models.CharField(max_length=255, null=True)
bcc_email = models.CharField(max_length=255, null=True)
cc_email = models.CharField(max_length=255, blank=True, null=True)
bcc_email = models.CharField(max_length=255, blank=True, null=True)
status = models.IntegerField(choices=Status.choices, default=Status.PENDING)
last_attempt = models.DateTimeField(null=True)
error = models.TextField(null=True)
Expand All @@ -65,7 +64,7 @@ def send(self):
to=self.to_email.split(","),
cc=cc,
bcc=bcc,
from_email=f"Houston ARTCC <{self.from_email or os.getenv("EMAIL_ADDRESS")}>",
from_email=f"Houston ARTCC <{self.from_email}>",
body=self.text_body,
alternatives=[(self.html_body, "text/html")],
).send()
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ All commands assume that you are at the root of the `zhu-core` repository that y
| `EMAIL_HOST_USER` | Email server username | `"username"` |
| `EMAIL_HOST_PASSWORD` | Email server password | `"password"` |
| `EMAIL_USE_TLS` | Use TLS for SMTP | `True` |
| `EMAIL_ADDRESS` | Email address used for outgoing mail | `"[email protected]"` |
| `EVENTS_WEBHOOK_URL` **[Optional]** | Discord channel webhook for posting events | |
</details>
Expand Down

0 comments on commit 2490cc2

Please sign in to comment.