Closed Divyessh closed 1 year ago
Hi thanks for the PR, seems like you have not updated the lock file, could you update the dependencies also?
Thank You @sabuhish , I have updated the poetry lock and dependencies.
Thanks, @Divyessh for this commit. I understand you want to make it compatible with starlette, the feature has not been removed, it has been taken into another function. Every file we send has different content types, I believe we must support specifying the content type.
The feature was discussed here; https://github.com/encode/starlette/pull/1413/files
@sabuhish ,
The reason for this PR was that right now, if we install fastapi==0.92
, it will install starlette==0.25
, which is not compatible with the present stage of fastapi-mail==1.2.5
.
So the latest version of fastapi-mail
is right now not compatible with latest version of fastapi
or starlette
@sabuhish Here is a minimal reproducible example:
Install the packages
pip install fastapi pip install fastapi-mail
Create a
file.txt
file Create the filetest.py
and enter following:from fastapi_mail import MessageSchema
message = MessageSchema( subject="Test", recipients=["test@gmail.com"], body="Test", subtype="html", attachments=["file.txt"], )
If we run the `test.py` file, we will face the following error:
pydantic.error_wrappers.ValidationError: 1 validation error for MessageSchema attachments UploadFile.init() got an unexpected keyword argument 'content_type' (type=type_error)
I understand your concern, but not agree with removing the feature of content_type. it supports via headers, you can old feature by passing headers https://github.com/encode/starlette/blob/master/starlette/datastructures.py#L452
@sabuhish, No problem, I have added the content-type to the headers instead. Thanks
Thanks, @Divyessh, now it looks fine actually.
Update the UploadFile function to make it compatible with newer versions of starlette.
-> Remove the
content_type
argument (which was earlier being passed to UploadFile)file fastapi_mail/schemas.py MessageSchema
-> Update dependencies inpyproject.toml