2014-04-02 71 views

回答

0

這應該工作在下面,如果它不,我會刪除評論:

import os 
os.system('echo 「Body text」 | mail -s Subject [email protected]') 
0

將下面的一個名爲「SEND_EMAIL」文件

#!/usr/bin/python 

import sys 
import os 

address = sys.argv[1] 
subject = sys.argv[2] 
message = sys.argv[3] # Probably want to do some escaping on this and subject 

os.system('echo "%s" | mail -s "%s" %s' % (message, subject, address)) 

將這個文件對您的PATH並運行以下命令以使其可執行:

chmod +x send_email 

現在你應該能夠發送電子郵件如下:

send_email [email protected] "Important Subject" "Here is a message"