fix: permit email sending when recipients, cc are empty but bcc has value
This commit is contained in:
parent
4621cb33fc
commit
39caf442e9
2 changed files with 11 additions and 7 deletions
|
|
@ -271,7 +271,7 @@ class CommunicationEmailMixin:
|
|||
)
|
||||
bcc = self.get_mail_bcc_with_displayname(is_inbound_mail_communcation=is_inbound_mail_communcation)
|
||||
|
||||
if not (recipients or cc):
|
||||
if not (recipients or cc or bcc):
|
||||
return {}
|
||||
|
||||
final_attachments = self.mail_attachments(
|
||||
|
|
|
|||
|
|
@ -664,7 +664,7 @@ class QueueBuilder:
|
|||
if self._unsubscribed_user_emails is not None:
|
||||
return self._unsubscribed_user_emails
|
||||
|
||||
all_ids = list(set(self.recipients + self.cc))
|
||||
all_ids = list(set(self.recipients + self.cc + self.bcc))
|
||||
|
||||
EmailUnsubscribe = DocType("Email Unsubscribe")
|
||||
|
||||
|
|
@ -698,6 +698,10 @@ class QueueBuilder:
|
|||
unsubscribed_emails = self.get_unsubscribed_user_emails()
|
||||
return [mail_id for mail_id in self.cc if mail_id not in unsubscribed_emails]
|
||||
|
||||
def final_bcc(self):
|
||||
unsubscribed_emails = self.get_unsubscribed_user_emails()
|
||||
return [mail_id for mail_id in self.bcc if mail_id not in unsubscribed_emails]
|
||||
|
||||
def get_attachments(self):
|
||||
attachments = []
|
||||
if self._attachments:
|
||||
|
|
@ -725,7 +729,7 @@ class QueueBuilder:
|
|||
attachments=self._attachments,
|
||||
reply_to=self.reply_to,
|
||||
cc=self.final_cc(),
|
||||
bcc=self.bcc,
|
||||
bcc=self.final_bcc(),
|
||||
email_account=email_account,
|
||||
expose_recipients=self.expose_recipients,
|
||||
inline_images=self.inline_images,
|
||||
|
|
@ -752,7 +756,7 @@ class QueueBuilder:
|
|||
"""
|
||||
final_recipients = self.final_recipients()
|
||||
queue_separately = (final_recipients and self.queue_separately) or len(final_recipients) > 100
|
||||
if not (final_recipients + self.final_cc()):
|
||||
if not (final_recipients + self.final_cc() + self.final_bcc()):
|
||||
return []
|
||||
|
||||
queue_data = self.as_dict(include_recipients=False)
|
||||
|
|
@ -760,7 +764,7 @@ class QueueBuilder:
|
|||
return []
|
||||
|
||||
if not queue_separately:
|
||||
recipients = list(set(final_recipients + self.final_cc() + self.bcc))
|
||||
recipients = list(set(final_recipients + self.final_cc() + self.final_bcc()))
|
||||
q = EmailQueue.new({**queue_data, **{"recipients": recipients}}, ignore_permissions=True)
|
||||
send_now and q.send()
|
||||
return q
|
||||
|
|
@ -786,7 +790,7 @@ class QueueBuilder:
|
|||
frappe_mail_client = None
|
||||
smtp_server_instance = None
|
||||
for r in final_recipients:
|
||||
recipients = list(set([r, *self.final_cc(), *self.bcc]))
|
||||
recipients = list(set([r, *self.final_cc(), *self.final_bcc()]))
|
||||
q = EmailQueue.new({**queue_data, **{"recipients": recipients}}, ignore_permissions=True)
|
||||
if not frappe_mail_client and not smtp_server_instance:
|
||||
email_account = q.get_email_account(raise_error=True)
|
||||
|
|
@ -836,7 +840,7 @@ class QueueBuilder:
|
|||
"communication": self.communication,
|
||||
"send_after": self.send_after,
|
||||
"show_as_cc": ",".join(self.final_cc()),
|
||||
"show_as_bcc": ",".join(self.bcc),
|
||||
"show_as_bcc": ",".join(self.final_bcc()),
|
||||
"email_account": email_account_name or None,
|
||||
"email_read_tracker_url": self.email_read_tracker_url,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue