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

Alternative to PR 669 #675

Merged
merged 11 commits into from
Feb 29, 2024
Merged

Alternative to PR 669 #675

merged 11 commits into from
Feb 29, 2024

Conversation

derks
Copy link
Member

@derks derks commented Feb 27, 2024

SMTP Extension Bug Fixes and Enhancements

TomFreudenberg and others added 10 commits January 18, 2024 05:13
1. Respect empty CC and BCC and do not deliver <> to SMTP Server
2. Allow TLS also on non-SSL sessions
3. Turn on debugging before TLS to see that log as well
4. Check for parameter `files` and empty if missed
5. Loop through files and append to attachments
6. Allow Attachment Disposition Name differ from Filename by path/filename.ext=attname.ext
7. Allow body to send in text and html by list or dict
Fix linter issues
- Resolves Pull Request 669
- Resolves Issue 667
- Resolves Issue 668
@derks
Copy link
Member Author

derks commented Feb 27, 2024

@TomFreudenberg this PR is based on the work you did in #669. Curious if you might review the changes and confirm that it suits your needs. Some minor changes:

  • Files list can be a list of strings (paths) [ <path>, <path>, ... ], or a list of tuples [ (<alt_name>, <path>), ... ] to support the alternative names. I didn't want to delimit on = as it's possible the filename could have a = in it. I think this is cleaner.
  • The send method now takes <text> or list [ <text>, <html> ] ... It felt redundant to also support a dict so I removed that.

@TomFreudenberg
Copy link
Contributor

Hi @derks

I will check that today and come up with my response. In general it looks fine so far. Thanks for your invest on that!

part = MIMEBase('application', 'octet-stream')

# support for alternative file name if its tuple
# like (filename.ext=attname.ext)
Copy link
Contributor

@TomFreudenberg TomFreudenberg Feb 27, 2024

Choose a reason for hiding this comment

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

Comment should be

# like ['filename.ext', 'attname.ext']

Copy link
Contributor

Choose a reason for hiding this comment

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

In case you change the order in the list,
the comment must be:

# like ['attname.ext', 'path/filename.ext']

from ..utils.misc import minimal_logger, is_true


LOG = minimal_logger(__name__)
Copy link
Contributor

@TomFreudenberg TomFreudenberg Feb 27, 2024

Choose a reason for hiding this comment

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

Hi @derks

why do you prefer to create a seperate LOG in each library than using the app.log general instance?

I prefer using self.app.log.debug() - am I wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

@TomFreudenberg extensions do not use the app logger by design, I can't recall exactly but was probably partly to clearly separate framework from application as well as being able to log before app is fully setup. By request others have asked to further remove framework logging which is why it will be disabled by default in 3.2, and why the project template disables it by default now.

I actually mention in this deprecation the idea of using app.log once it is available.

@TomFreudenberg
Copy link
Contributor

Please find my comments above. Everything alse covers all my requirements, thanks for your rework and adding that to Cement.

@TomFreudenberg
Copy link
Contributor

TomFreudenberg commented Feb 28, 2024

@derks Please check my review, this is an important change.

You won't add an attachment including the path of the file from where it comes as attachment name!

@derks
Copy link
Member Author

derks commented Feb 28, 2024

Oof... good catch. Thank you I'll fix that.

@derks derks merged commit 9243c30 into main Feb 29, 2024
4 checks passed
attname = in_path[0]
path = in_path[1]
else:
attname = in_path
Copy link
Contributor

Choose a reason for hiding this comment

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

attname by default should not contain a path for attachment disposition

attname = os.path.basename(in_path)

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if you export the basename() function somewhere in cement like fs?

@TomFreudenberg
Copy link
Contributor

Hey @derks

I add some comments again, hopefully you like this kind of conversation. Otherwise give me a hint to stop.

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.

None yet

2 participants