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

Feature/Attachments #32

Merged
merged 17 commits into from
Jan 23, 2019
Merged

Feature/Attachments #32

merged 17 commits into from
Jan 23, 2019

Conversation

seshrs
Copy link
Contributor

@seshrs seshrs commented Jan 5, 2019

Added an option to send attachments with each email. This can be configured using an "attachment list" text file, which must be supplied as an option to mailmerge. The updated README explains the details of how it can be used. A functional test using attachments has also been added.

I verified that attachments were correctly identified by Gmail-based clients. I am open to suggestions on how to improve the functionality or style of code in this PR. Thanks!

seshrs added 5 commits January 4, 2019 15:20
- Added an option to __main__
- Added sample attachment list template
- Updated main driver to attach files to multipart email
@seshrs
Copy link
Contributor Author

seshrs commented Jan 5, 2019

Ah, just saw that there's an issue for this: #20

@awdeorio
Copy link
Owner

awdeorio commented Jan 6, 2019

This is great! What do you do you think about using an pseudo-header to specify attachments? See discussion here #20 (comment)

@seshrs
Copy link
Contributor Author

seshrs commented Jan 7, 2019

Thanks! The pseudo-header is possible. My thoughts:

  • Attachments would result in non-standard emails. But maybe that's the direction mailmerge should go, given Markdown Support #26.
  • The attachments would have to be separated by commas or semicolons, and all on one line. Would that look cluttered? (Perhaps not, given that most people don't send too many attachments in emails.)

Copy link
Owner

@awdeorio awdeorio left a comment

Choose a reason for hiding this comment

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

We're getting close!

Another question: what happens if a file has a space in it?

What if I use an absolute path? Possibly relevant: https://docs.python.org/2/library/os.path.html#os.path.abspath

What if I use a path that has a backslash, e.g., on Windows?

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
mailmerge/api.py Outdated Show resolved Hide resolved
mailmerge/api.py Show resolved Hide resolved
tests/test_send_attachment.py Show resolved Hide resolved
@seshrs
Copy link
Contributor Author

seshrs commented Jan 9, 2019

Regarding your other comments:

  • Windows-style separators: I realize I missed to use os.path.join in api.py:83. I think making this change should ensure that Windows style paths work: I can try to validate this.
  • Absolute paths: I think os.path.isabs will help identify such paths. According to the docs, it also works as expected on Windows too.

Thanks for bringing these points up! Will push a new iteration soon.

README.md Outdated Show resolved Hide resolved
@awdeorio
Copy link
Owner

I scratched a few itches, editing the README directly. Take a second look if you think it's OK.

@seshrs
Copy link
Contributor Author

seshrs commented Jan 11, 2019

The README looks much cleaner now. Thanks for the input!

@awdeorio
Copy link
Owner

This is looking great! Once the (newly added CI) tests pass, it'll be ready to merge!

Used a hack to work around a bug in the backports email module's Message.set_boundary method. See the comments in this commit for details about the workaround.
@seshrs
Copy link
Contributor Author

seshrs commented Jan 18, 2019

The original changes failed on python2 because of a bug in the future module. Message._headers is represented as a custom list object to enable support for both python2 and python3. Unfortunately, the Message.set_boundary method converts this to a native list, which breaks some functionality in python2.

(Edit: I've created an issue in the future repository and have submitted a PR there with a fix. See PythonCharmers/python-future#429 and PythonCharmers/python-future#430)

I've implemented a work-around to avoid the set_boundary method from being called. What do you think of it? (I'm open to suggestions to making the "hack" less hacky!)

@awdeorio
Copy link
Owner

Looks great! I'm going to merge, then create an issue to remove the Message._headers work-around after your upstream PR is accepted.

@awdeorio awdeorio merged commit 67e7cf0 into awdeorio:develop Jan 23, 2019
@awdeorio awdeorio mentioned this pull request Jan 23, 2019
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.

2 participants