
import sys
import os

# total arguments
n = len(sys.argv)

if (n != 4):
    print(f"\n   Usage: python {sys.argv[0]} emailAddr inputFile subject\n")
    print("\nThis program sends out inputFile to emailAddr\n")
    exit(0)

emailAddr = sys.argv[1]
inpFile = sys.argv[2]
subject = sys.argv[3]

if (not os.path.isfile(inpFile)):
    print(f"\n   Error: inputfile '{inpFile}' does NOT exists\n")
    exit(0)

#mail_body = "This message was sent with Python."


e = emailAddr
# print(e)

print(f"Sending '{inpFile}' to '{e}'")

cmd = "python sendmail.py "    
cmd = cmd + str(e) + " " + str(inpFile) + " '" + str(subject) + "'"

#   print(f"{cmd}")         # DEBUG: show command

# ==================================================
# Uncomment to enable sending email
# ==================================================
#   os.system(cmd)




