return 5** if CannotCreateContactForReverseAlias
This commit is contained in:
parent
ed39d47e7a
commit
01ba5e8bf0
|
@ -59,4 +59,5 @@ E522 = (
|
||||||
"at a rate that prevents additional messages from being delivered."
|
"at a rate that prevents additional messages from being delivered."
|
||||||
)
|
)
|
||||||
E523 = "550 SL E523 Unknown error"
|
E523 = "550 SL E523 Unknown error"
|
||||||
|
E524 = "550 SL E524 Wrong use of reverse-alias"
|
||||||
# endregion
|
# endregion
|
||||||
|
|
|
@ -1574,7 +1574,7 @@ class Contact(Base, ModelMixin):
|
||||||
# make sure contact.website_email isn't a reverse alias
|
# make sure contact.website_email isn't a reverse alias
|
||||||
orig_contact = Contact.get_by(reply_email=website_email)
|
orig_contact = Contact.get_by(reply_email=website_email)
|
||||||
if orig_contact:
|
if orig_contact:
|
||||||
raise CannotCreateContactForReverseAlias
|
raise CannotCreateContactForReverseAlias(str(orig_contact))
|
||||||
|
|
||||||
Session.add(new_contact)
|
Session.add(new_contact)
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ from app.errors import (
|
||||||
VERPForward,
|
VERPForward,
|
||||||
VERPReply,
|
VERPReply,
|
||||||
MailSentFromReverseAlias,
|
MailSentFromReverseAlias,
|
||||||
|
CannotCreateContactForReverseAlias,
|
||||||
)
|
)
|
||||||
from app.log import LOG, set_message_id
|
from app.log import LOG, set_message_id
|
||||||
from app.models import (
|
from app.models import (
|
||||||
|
@ -2335,6 +2336,21 @@ class MailHandler:
|
||||||
try:
|
try:
|
||||||
ret = self._handle(envelope, msg)
|
ret = self._handle(envelope, msg)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
# happen if reverse-alias is used during the forward phase
|
||||||
|
# as in this case, a new reverse-alias needs to be created for this reverse-alias -> chaos
|
||||||
|
except CannotCreateContactForReverseAlias as e:
|
||||||
|
LOG.w(
|
||||||
|
"Probably due to reverse-alias used in the forward phase, "
|
||||||
|
"error:%s mail_from:%s, rcpt_tos:%s, header_from:%s, header_to:%s",
|
||||||
|
e,
|
||||||
|
envelope.mail_from,
|
||||||
|
envelope.rcpt_tos,
|
||||||
|
msg[headers.FROM],
|
||||||
|
msg[headers.TO],
|
||||||
|
)
|
||||||
|
Session.rollback()
|
||||||
|
return status.E524
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.e(
|
LOG.e(
|
||||||
"email handling fail with error:%s mail_from:%s, rcpt_tos:%s, header_from:%s, header_to:%s, saved to %s",
|
"email handling fail with error:%s mail_from:%s, rcpt_tos:%s, header_from:%s, header_to:%s, saved to %s",
|
||||||
|
|
Loading…
Reference in a new issue