Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bcc not working #7

Closed
rfreis opened this issue Aug 13, 2021 · 1 comment
Closed

Bcc not working #7

rfreis opened this issue Aug 13, 2021 · 1 comment

Comments

@rfreis
Copy link
Contributor

rfreis commented Aug 13, 2021

Hi guys! How are you doing?

First of all, congratulations for your job with this package! It has been really helpful using it!

While sending emails, I realized that Django's EmailMessage doesn't attach the bcc recipient's to the message, and it instead uses separately the recipients() which works good with other backends like smtp.

To workaround that, I made a small change on GmailBackend.send_message. If you find useful, I can open a new pull request to update the package

Thanks
Rodrigo

class GmailBackendWithBcc(GmailBackend):
    def send_message(self, email_message):
        if not email_message.recipients():
            return False
        message = email_message.message()
        if email_message.bcc:
            email_message._set_list_header_if_not_empty(message, 'Bcc', email_message.bcc)
        raw_message = {'raw': base64.urlsafe_b64encode(message.as_bytes()).decode()}
        return self.service.users().messages().send(userId=self.user_id, body=raw_message)
@dolfim
Copy link
Owner

dolfim commented Jun 26, 2022

Solved in #12.
Thanks for the contribution.

@dolfim dolfim closed this as completed Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants