Hi,
I am developing a proxy where email needs to be sent out to customers when they exceed requests over a certain number. I am trying to find out the best way to handle this functionality.
- Is there an out of the box default feature from Apigee for such a case when quota policy failure occurs?
(Unanswered or not clear: https://docs.apigee.com/api-platform/monetization/set-limit-notifications)) - How do I set up email callout using javascript or python script in Apigee?
check below python code snippet using python call execution at quota policy failure. I found above code snippet in one of the pages of Apigee community which is not working for me.
I have confusion over SMTP host,username and password.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
smtpserver.connect()
host = flow.getVariable("emailhost");
port = flow.getVariable("emailport");
username = flow.getVariable("emailusername");
password = flow.getVariable("emailpassword");
mailTo = flow.getVariable("email");
bodyMessage = "Quota Exceeded";
subject = flow.getVariable("emailsubject");
mailFrom = flow.getVariable("emailfrom");
ssl = 'true';
auth = 'true';
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = mailFrom
msg['To'] = mailTo
msg.attach( MIMEText(bodyMessage, 'html'))
smtpserver = smtplib.SMTP(host,port)
if ssl=='true':
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
if auth=='true':
smtpserver.login(username, password)
smtpserver.sendmail(mailFrom, mailTo, msg.as_string())
smtpserver.quit()