如何在Linux上打开用户的首选邮件应用程序? [英] How to open the user's preferred mail application on Linux?

查看:165
本文介绍了如何在Linux上打开用户的首选邮件应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用python-gtk写了一个简单的本机GUI脚本。现在我想给用户一个按钮来发送带有附件的电子邮件。



脚本在Linux桌面上运行。有没有办法打开用户的首选邮件应用程序并附加文件?

解决方案

要调用的linux命令将是 xdg-email ,这是xdg-utils包的一部分,它是大多数linux桌面(至少默认在arch,debian,ubuntu)。



xdg-email是使用用户首选电子邮件作曲家发送邮件的命令行工具。



如果他们已经正确设置了其默认应用程序,它将打开其默认邮件客户端。您可以传递参数以填写各种邮件字段(至,cc,主题,正文等)以及要附加的文件的文件名。



从你的python脚本你可以使用os.system()或子进程模块来调用它。


I wrote a simple native GUI script with python-gtk. Now I want to give the user a button to send an email with an attachment.

The script runs on Linux desktops. Is there a way to open the user's preferred mail application and attach a file?

解决方案

The linux command to call would be xdg-email, part of the xdg-utils package, which is on most linux desktops (at least by default on arch, debian, ubuntu).

xdg-email is a "command line tool for sending mail using the user's preferred e-mail composer".

provided they've set up their default applications properly, it will open their default mail client. You can pass it arguments to fill in various mail fields (to, cc, subject, body etc.), as well as file names of the files to attach.

From your python script you could call it using os.system() or the subprocess module..

这篇关于如何在Linux上打开用户的首选邮件应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆