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

No specification of attachment file types #239

Closed
Magnati opened this issue Apr 15, 2019 · 3 comments
Closed

No specification of attachment file types #239

Magnati opened this issue Apr 15, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@Magnati
Copy link

Magnati commented Apr 15, 2019

Hello @liiight

This is kind of a feature request/second-layer-bug-but-not-realy-a-bug.

In notifiers/providers/email.py:120ff

@staticmethod
    def _add_attachments(data: dict, email: EmailMessage) -> EmailMessage:
        for attachment in data["attachments"]:
            file = Path(attachment).read_bytes()
            part = MIMEApplication(file)
            part.add_header("Content-Disposition", "attachment", filename=attachment)
            email.attach(part)
return email

... the header of the MIME application is set to the most generic type for attachments.
For all thunderbird users this creates the issue, that the attachments are not shown, since thunderbirds has a long time bug of not showing the attachments if the file type is not further specified.

So this is a request to either

  • make it possible to define the file-type over parameter,
  • or implement a file-type detection in Notifiers itself.

Greetings,
Magnati

@liiight liiight self-assigned this Apr 16, 2019
@liiight liiight added this to the 1.2.0 milestone Jun 23, 2019
@liiight
Copy link
Owner

liiight commented Jun 23, 2019

hi @Magnati, can you provide more context for this? perhaps an example with a specific file-type?

liiight added a commit that referenced this issue Jun 23, 2019
liiight added a commit that referenced this issue Jun 23, 2019
* added mimetype guess. Closes #239

* updated changelog

* added mimetype tests
liiight added a commit that referenced this issue Jun 24, 2019
* added mimetype guess. Closes #239

* updated changelog

* added mimetype tests
liiight added a commit that referenced this issue Jun 24, 2019
* added mimetype guess. Closes #239

* updated changelog

* added mimetype tests
@Magnati
Copy link
Author

Magnati commented Jun 26, 2019

Sorry for the late response.

The file type for which it occurred for me is .zip.
Thunderbird: 60.6.1 (64-Bit)
Python: 3.7.1
notifier: 1.0.4

Below a minimal example which reproduced the behaviour in my case.

import os

import notifiers
import pathlib

def send_zip(directory, mail):

    p = notifiers.get_notifier("email")

    # server credentials
    user = "<your user>"
    pw = "<your password>"
    port = 12345
    host = "<your host>"

    status = p.notify(
        to=mail,
        username=user,
        password=pw,
        message="Test sending.",
        subject="Test sending.",
        ssl=True,
        port=port,
        html=host,
        host="smtp.ambrosys.de",
        attachments=[directory],
    )
    print(status)


if __name__ == "__main__":
    mail = "yourl@mail.com"
    directory = "/your/file/path.zip"
    send_zip(directory, mail)

@liiight
Copy link
Owner

liiight commented Jun 26, 2019

I actually fixed this in #267.

If you'd like sending an email to python.notifiers@gmail.com I'd send you a test email back

@liiight liiight added bug and removed enhancement labels Jun 26, 2019
liiight added a commit that referenced this issue Jul 25, 2019
* added mimetype guess. Closes #239

* updated changelog

* added mimetype tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants