Created
January 13, 2019 14:33
-
-
Save ryujaehun/77aaf0802fd747714e33f25fc58556c3 to your computer and use it in GitHub Desktop.
sendmail.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python3 | |
from time import gmtime, strftime | |
import os | |
def send_mail(from_address=None,content=None,copy_address=None,subject=None, file=None): | |
if from_address is None: | |
from_address='[email protected]' | |
elif subject is None: | |
subject=strftime("%Y-%m-%d %H:%M:%S", gmtime()) | |
temp="" | |
if content is not None: | |
temp='echo "' +content+'" |' | |
temp+=' mutt -s '+'"'+subject+'" '+from_address | |
if copy_address is not None: | |
temp+=" -c "+copy_address | |
if file is not None: | |
temp+=" -a "+file | |
os.system(temp) | |
if __name__ == "__main__": | |
# test | |
os.system('touch a.txt') | |
os.system('echo " test test"> a.txt') | |
os.system('rm a.txt') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment