mirror of
https://github.com/proxmoxer/proxmoxer.git
synced 2026-04-24 22:56:01 +03:00
[GH-ISSUE #171] htmlmail option for Proxmox Mail Gateway #94
Labels
No labels
backend:https
backend:local
backend:openssh
backend:ssh_paramiko
pull-request
status:ansible-issue
status:help-wanted
status:info-needed
status:proxmox-issue
status:review-needed
type:bug 🐞
type:dependency ⛓️
type:docs 📝
type:enhancement ⏫
type:maintenance 🛠️
type:meta
type:question ❓
type:request ✋
type:testing 🧪
version:1.x
version:latest
version:py2
version:py3
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/proxmoxer#94
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MrDiba on GitHub (Aug 26, 2024).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/171
Originally assigned to: @jhollowe on GitHub.
Python version: 3.12.3
Proxmoxer version: 2.1.0 using https backend
PMG version: 7.3-11
I'm creating an custom application around the Proxmox Mail Gateway API and I ran into an issue where I can not receive the
htmlmailversion from an quarantine content.For example:
proxmox.quarantine.content.get(id=mail_id)gets the data from/api2/json/quarantine/contentIn the API documentation there is the following description:
Get email data. There is a special formatter called 'htmlmail' to get sanitized html view of the mail content (use the '/api2/htmlmail/quarantine/content' url).But when I try to do
proxmox.htmlmail.quarantine.content.get(id=mail_id)it errors with:Is there a way to get the
htmlmailusing Proxmoxer or can someone guide me to the place where to impement it so I can open a pull request?@MrDiba commented on GitHub (Aug 26, 2024):
@JONTY650413 could you please elaborate what the fix is you are proposing? The speed in which you answered with this supposing 'fix' looks like a scam.
@jhollowe commented on GitHub (Aug 26, 2024):
sorry about that. I have reported them to GitHub for malicious content, blocked the user, and deleted the comment. Do not click the link that was sent by that user.
@jhollowe commented on GitHub (Aug 26, 2024):
Can you try using proxmoxer 2.0.1? #170 seems slightly similar to this and I'm wondering if there is a bug in 2.1.0.
@MrDiba commented on GitHub (Aug 27, 2024):
Hi @jhollowe, thank you for your quick action on the spam and your reply.
I have tried downgrading to version 2.0.1, but it gives me the same results.
Edit:
Taking a look at the code:
github.com/proxmoxer/proxmoxer@f72466614a/proxmoxer/backends/https.py (L251-L265)It looks like the
jsonpart of the url is set over here, so i tried to change my code toproxmox_html = ProxmoxAPI( "pmg.example.com", port=443, user=Config.PMG_API_USERNAME, password=Config.PMG_API_PASSWORD, service='pmg', mode="htmlmail" )But that results in errors in the authentication.
My assumption is that
proxmox.htmlmail.quarantine.content.get(id=mail_id)results in an url like this:/api2/json/htmlmail/quarantine/content@MrDiba commented on GitHub (Aug 27, 2024):
Edit, this breaks more stuff than it fixes...
I have created an small but (in my opinion) ugly patch:
github.com/proxmoxer/proxmoxer@f72466614a/proxmoxer/core.py (L91-L96)That piece of code handles the parameters, by adding an if statement that when the parameter is
htmlmailit will remove the json from the base url:I would not advice to use this, but it works until there is an more permanent solution.
The output of
proxmox.htmlmail.quarantine.content.get(id=mail_id)is an dict containing{'errors': b'<email in html>'}@jhollowe commented on GitHub (Aug 27, 2024):
I don't have a PMG setup to test against. Do I need actual emails flowing through it to test this or can I just spin up a fresh PMG and still be able to test this?
@MrDiba commented on GitHub (Aug 28, 2024):
I just tried to call
spam_html = proxmox.htmlmail.quarantine.content.get()without an ID parameter and that gives the same501 Not Implementederror so I assume it will work without having mail flowing through.The documentation can be found here: https://pmg.proxmox.com/pmg-docs/api-viewer/index.html#/quarantine/content I can test patches for you if needed.
@MrDiba commented on GitHub (Sep 4, 2024):
I have implemented an workaround in my code like this:
This way it only injects the new url when calling the
htmlmailendpoint.@morph027 commented on GitHub (Sep 7, 2024):
You could create a context manager for this, which you can re-use in other calls too.