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

Improve Resend documentation and checks #293

Merged
merged 4 commits into from
May 24, 2024

Conversation

pfouque
Copy link
Collaborator

@pfouque pfouque commented May 24, 2024

After 2 issues related to the usage of the reply() function, it wasn't clear what is the type of message variable.

  • Improve documentation, with an example
  • Add check and raise ValueError('Message must be an instance of django.core.mail.EmailMessage')
  • BONUS: Fix doc format for "Supported Mailbox Types"
Screenshot 2024-05-24 at 09 26 19

@pfouque pfouque merged commit 8992bab into coddingtonbear:master May 24, 2024
5 checks passed
@pfouque pfouque deleted the resend_poor_type_checking branch May 24, 2024 07:27
from django.core.mail import EmailMessage

message.reply(
EmailMessage(subject="pong", body="pongpong")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to also add the to field so that the email was actually sent.

from django.core import mail

def reply_to_message(message, subject, messagebody):
    rpl = mail.EmailMessage(
        subject=subject,
        body=messagebody,
        to=[message.from_header],
    )
    message.reply(rpl)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it might be worth adding that to the reply method?

if not to:
  add to from reply_to or from_header

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting!
Is it something to document or should we expect the "reply" function to set it automatically...
WDYT @Pietro395 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Is it something to document or should we expect the "reply" function to set it automatically... WDYT @Pietro395 ?

Interesting observation @enaut
In my opinion since you are using the reply function I would expect the “to” to be set automatically if not specified.

I think that's what a user would expect

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

Successfully merging this pull request may close these issues.

3 participants