How can I write a python plugin for an mail client Evolution
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
-
- Level 1
- Posts: 1
- Joined: Wed Aug 02, 2023 5:11 am
How can I write a python plugin for an mail client Evolution
I need to write a mail plugin Evolution 3.32.4-alt1 preferably in python. Plugin functionality: If the user sends an email not to the organization’s domain, then a dialog box with a warning about this and the “Cancel” and “Send” buttons should be displayed. How can this be implemented? How to make Evolution recognize the plugin?
Last edited by LockBot on Fri Feb 02, 2024 11:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How can I write a python plugin for an mail client Evolution
Might be better suited for the Programming & Development subforum. viewforum.php?f=120
-
- Level 1
- Posts: 6
- Joined: Thu Dec 14, 2023 5:07 am
- Location: USA
- Contact:
Re: How can I write a python plugin for an mail client Evolution
As per knowledge, it's very simple-
Follow these steps-
1. Install Required Packages
2. Write the Plugin Code:
Create a Python script for your plugin (https://packaging.python.org/en/latest/ ... g-plugins/).
Let's call it 'org_domain_warning.py':
3. Install the Plugin:
4. Test the Plugin
I followed the same steps while I was create Plugin functions for this DevOps model.
Follow these steps-
1. Install Required Packages
Code: Select all
sudo apt-get install evolution-data-server-dev python3-gi
Create a Python script for your plugin (https://packaging.python.org/en/latest/ ... g-plugins/).
Let's call it 'org_domain_warning.py':
Code: Select all
#!/usr/bin/env python3
from gi.repository import GObject
from gi.repository import Camel
from gi.repository import Evolution
class OrgDomainWarningPlugin(GObject.Object, Evolution.MailFilter):
def filter(self, filter_str, message, user_data):
# Extract recipient email addresses
recipients = [addr.get_address() for addr in message.get_recipients()]
# Check if any recipient is outside the organization's domain
if any('your_organization_domain.com' not in recipient for recipient in recipients):
# Display warning dialog
dialog = Evolution.Dialog(
'Warning',
'You are sending an email outside the organization\'s domain. Are you sure you want to proceed?',
Evolution.DialogFlags.MODAL | Evolution.DialogFlags.NO_SEPARATOR,
Evolution.STOCK_DIALOG_WARNING,
Evolution.Button('Cancel', Evolution.ResponseType.CANCEL),
Evolution.Button('Send', Evolution.ResponseType.ACCEPT)
)
response = dialog.run()
dialog.destroy()
# If the response is 'Cancel', stop sending the email
if response == Evolution.ResponseType.CANCEL:
return Evolution.MailFilterResult.STOP
# Continue sending the email
return Evolution.MailFilterResult.CONTINUE
# Register the plugin
GObject.type_register(OrgDomainWarningPlugin)
Evolution.MailFilter.register_type(OrgDomainWarningPlugin)
Code: Select all
sudo cp org_domain_warning.py /usr/lib/evolution/3.32/plugins/
I followed the same steps while I was create Plugin functions for this DevOps model.
Thanks
Jacob Mall
Jacob Mall