mirror of
https://github.com/simple-login/app.git
synced 2025-10-08 06:24:50 +08:00
Create alias on-the-fly if the corresponding custom domain allows catch-all
This commit is contained in:
parent
96bb37f0f6
commit
f08ca682c0
1 changed files with 16 additions and 1 deletions
|
@ -44,6 +44,7 @@ from app.email_utils import (
|
||||||
get_email_part,
|
get_email_part,
|
||||||
send_email,
|
send_email,
|
||||||
add_dkim_signature,
|
add_dkim_signature,
|
||||||
|
get_email_domain_part,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
|
@ -108,7 +109,21 @@ class MailHandler:
|
||||||
gen_email = GenEmail.get_by(email=alias)
|
gen_email = GenEmail.get_by(email=alias)
|
||||||
if not gen_email:
|
if not gen_email:
|
||||||
LOG.d("alias %s not exist")
|
LOG.d("alias %s not exist")
|
||||||
return "510 Email not exist"
|
|
||||||
|
# check if alias is custom-domain alias and if the custom-domain has catch-all enabled
|
||||||
|
alias_domain = get_email_domain_part(alias)
|
||||||
|
custom_domain = CustomDomain.get_by(domain=alias_domain)
|
||||||
|
if custom_domain and custom_domain.catch_all:
|
||||||
|
LOG.d("create alias %s for domain %s", alias, custom_domain)
|
||||||
|
|
||||||
|
gen_email = GenEmail.create(
|
||||||
|
email=alias,
|
||||||
|
user_id=custom_domain.user_id,
|
||||||
|
custom_domain_id=custom_domain.id,
|
||||||
|
)
|
||||||
|
db.session.commit()
|
||||||
|
else:
|
||||||
|
return "510 Email not exist"
|
||||||
|
|
||||||
user_email = gen_email.user.email
|
user_email = gen_email.user.email
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue