Adding mail flag to stats_report.py results in Unicode error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 491
- Forks
- 290
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 3
Description
When calling stats.py, works fine with the date parameters, when adding the mail (-m) flag, results in the following error:
Traceback (most recent call last):
File "/var/www/MISP/PyMISP/examples/stats_report.py", line 405, in
print_report(report_body, attachments, smtp_from, smtp_to, smtp_server, misp_url)
File "/var/www/MISP/PyMISP/examples/stats_report.py", line 312, in print_report
server.sendmail(smtp_from, smtp_to, msg.as_string())
File "/usr/lib/python3.10/smtplib.py", line 875, in sendmail
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 143201-143203: ordinal not in range(128)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/stats_report.py, especially print_report and the server.sendmail call shown in the traceback. Reproduce the report using the date parameters and then the -m flag, checking the generated message for non-ASCII content. Done means the mail-enabled report sends successfully without the UnicodeEncodeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100