0

我在 shell 中使用 mail 命令发送电子邮件:

echo "abc" | mail -s "Subject" abc@def.com

我想在python中使用这个命令,所以我写了以下内容:

call("echo abc" "|" "mail", "-s Subject", "abc@def.com", shell=True)

然后它给了我以下错误:

Original exception was:
Traceback (most recent call last):
  File "email.py", line 7, in <module>
    call("mail", "-s", "Subject", "abc@def.com", shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 493, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 629, in __init__
    raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer

这是什么原因?

4

1 回答 1

1

尝试调用这样的call方法

call(["mail", "-s", "'Subject'", "abc@def.com"], shell=True)

第2部分:

sudo touch /var/mail/<username>
sudo chown <username>:mail /var/mail/<username>
sudo chmod o-r /var/mail/<username>
sudo chmod g+rw /var/mail/<username>

取自这里

于 2013-04-13T15:43:22.563 回答