Skip to content

Instantly share code, notes, and snippets.

@ryujaehun
Created January 13, 2019 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryujaehun/77aaf0802fd747714e33f25fc58556c3 to your computer and use it in GitHub Desktop.
Save ryujaehun/77aaf0802fd747714e33f25fc58556c3 to your computer and use it in GitHub Desktop.
sendmail.py
#! /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='2013103902@khu.ac.kr'
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