mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
fix renewals, add email for vm expiration
This commit is contained in:
parent
0df186f5c3
commit
bf19241bed
4 changed files with 61 additions and 2 deletions
30
proxstar/mail.py
Normal file
30
proxstar/mail.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
|
||||
|
||||
def send_email(toaddr, subject, body):
|
||||
fromaddr = 'proxstar@csh.rit.edu'
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = fromaddr
|
||||
msg['To'] = toaddr
|
||||
msg['Subject'] = subject
|
||||
body = body
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
server = smtplib.SMTP('mail.csh.rit.edu', 25)
|
||||
server.starttls()
|
||||
text = msg.as_string()
|
||||
server.sendmail(fromaddr, toaddr, text)
|
||||
server.quit()
|
||||
|
||||
|
||||
def send_vm_expire_email(user, name, days):
|
||||
toaddr = "{}@csh.rit.edu".format(user)
|
||||
subject = 'Proxstar VM Expiration Notice'
|
||||
if days != 1:
|
||||
body = "{} is expiring in {} days. If you would like to keep this VM, please log into Proxstar and renew it.".format(
|
||||
name, days)
|
||||
else:
|
||||
body = "{} is expiring in {} day. If you would like to keep this VM, please log into Proxstar and renew it.".format(
|
||||
name, days)
|
||||
send_email(toaddr, subject, body)
|
Loading…
Add table
Add a link
Reference in a new issue