hjaltiatlason

python-mailgun-template

Jun 4th, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import requests
  3. import datetime
  4.  
  5. today = datetime.date.today()
  6.  
  7. def send_attachments():
  8.     return requests.post(
  9.         "https://api.mailgun.net/v3/mg.hjalti.me/messages",
  10.         auth=("api", "My-Private-API-KEY"),
  11.  
  12.         files = [("attachment", ("/home/hjalti/my-logs/"+str(today)+"_rclone_home_sync.log",
  13.                   open("/home/hjalti/my-logs/"+str(today)+"_rclone_home_sync.log", "rb").read()))],
  14.         data = {
  15.             "from": "hjalti@mg.hjalti.me",
  16.             "to":"hjalti@hjalti.me",
  17.             "subject":"Hello Hjalti - Your daily rclone log is here!!",
  18.             "text": "Hey, your daily Rclone log  is here!!"
  19.             })
  20. # Run the function
  21. send_attachments()
Add Comment
Please, Sign In to add comment