diff --git a/infrastructure/templates/infrastructure/emails/instance-created.txt b/infrastructure/templates/infrastructure/emails/instance-created.txt new file mode 100644 index 0000000..15f4f7d --- /dev/null +++ b/infrastructure/templates/infrastructure/emails/instance-created.txt @@ -0,0 +1,11 @@ +Hello {{ username }}!, + +The deployment job has run to completion and your Hostea instance is now online! +Credentials to admin account was sent in an earlier email, please contact +support if didn't receive it. + +Gitea: {{ gitea_uri }} +Woodpecker CI: {{ woodpecker_uri }} + +Cheers, +Hostea team diff --git a/infrastructure/utils.py b/infrastructure/utils.py index 45393a5..707cbc6 100644 --- a/infrastructure/utils.py +++ b/infrastructure/utils.py @@ -53,19 +53,23 @@ class Worker(Thread): job = self.job self.job = None email = job.instance.owned_by.email + + ctx = { + "gitea_uri": gitea_uri, + "woodpecker_uri": woodpecker, + "username": job.instance.owned_by.username, + } + body = render_to_string( + "infrastructure/emails/instance-created.txt", + context=ctx, + ) + + sender = settings.HOSTEA["EMAIL_SENDER_ADDRESS"] + send_mail( subject="[Hostea] Your Hostea instance is now online!", - message=f""" -Hello, - -The deployment job has run to completion and your Hostea instance is now online! -Credentials to admin account was sent in an earlier email, please contact -support if didn't receive it. - -Gitea: {gitea_uri} -Woodpecker CI: {woodpecker} -""", - from_email="No reply Hostea", # TODO read from settings.py + message=body, + from_email=f"No reply Hostea<{sender}>", # TODO read from settings.py recipient_list=[email], ) job.delete()