我sendmail.sh
在 Raspbian OS 上的脚本能够成功发送电子邮件。但是当从 python 脚本调用它时,我收到一条"mail: can not send message: process exited with non zero status"
错误消息。sendmail.sh
我已经通过手动运行验证了 ssmtp 配置正确。
发送邮件.sh
#!/bin/bash
echo "test" | mail -s "test msg" myemailaddress
sendmail.sh 的权限为 777。 sendmail.sh 和 sendmail.py 位于同一目录中。
发送邮件.py
import os
import subprocess
subprocess.call(['./sendmail.sh'])
我用来运行 python 的命令 - sudo python sendmail.py
。
我不明白为什么会发生错误。显然,python 正在调用sendmail.sh
,并且脚本设置了正确的权限。如果手动运行 sendmail.sh,则邮件发送正确。