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

UploadFile mimetype & name mangling #217

Open
foarsitter opened this issue Nov 14, 2024 · 0 comments
Open

UploadFile mimetype & name mangling #217

foarsitter opened this issue Nov 14, 2024 · 0 comments

Comments

@foarsitter
Copy link

When using a UploadFile as an attachment the file_meta is always None. This happens during the validation of MessageSchema:

def validate_file(cls, v):

In my opinion MailMsg.attach_file should be extended to support UploadFile and derive the mimetype from the content-type header.

content_type = file.headers.get("Content-Type", "application/octet-stream")
_maintype, _subtype = content_type.split("/")
part = MIMEBase(_maintype=_maintype, _subtype=_subtype)

When extending the FastMail class I discovered the usage of double underscored methods. What is the reason of applying name mangling here? In order to override __prepare_message I have to name the method _FastMail__prepare_message and that is not something I'm enthusiastic about ;)

class ExtendedFastMail(FastMail):
    async def _FastMail__prepare_message(
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

1 participant