小编Lio*_*gan的帖子

如何通过mailx和subprcoess发送邮件?

我是EE,试图编写一个脚本来简化使用Python的文件检查.出于某种原因,我们的IT不会让我访问我们的smtp服务器,并且只允许通过mailx发送邮件.所以,我想过从Python运行mailx并发送它,就像它在我的控制台中工作一样.唉,它给出了一个例外.请参阅下面的Linux日志:

***/depot/Python-3.1.1/bin/python3.1
Python 3.1.1 (r311:74480, Dec  8 2009, 22:48:08) 
[GCC 3.3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> process=subprocess.Popen('echo "This is a test\nHave a loook see\n" | mailx -s "Test Python" mymail@mycomopany.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/depot/Python-3.1.1/lib/python3.1/subprocess.py", line 646, in __init__
    errread, errwrite)
  File "/depot/Python-3.1.1/lib/python3.1/subprocess.py", line 1146, in _execute_child
    raise child_exception***
Run Code Online (Sandbox Code Playgroud)

我是Python的新手(现在从PERL迁移).有什么想法吗?

python subprocess

4
推荐指数
1
解决办法
9317
查看次数

标签 统计

python ×1

subprocess ×1