I'm having a problem with sending an email through Google App Engine with Python. I have a website running on a different host which contains a form posting to a Python script in GAE. The script works fine, but fails if I add the "send mail" function in my Python script. I've added:
self.response.headers['Access-Control-Allow-Origin']='*'
But I still get the error:
XMLHttpRequest cannot load http://www.summit-tech-help.appspot.com/. Origin http://summittechhelp.x10.mx is not allowed by Access-Control-Allow-Origin.
Here's my Python script.
import cgi,webapp2
from google.appengine.api import mail
class ProblemRedirect(webapp2.RequestHandler):
def post(self):
self.response.headers['Access-Control-Allow-Origin']='*'
problem_text = (cgi.escape(self.request.get('problem_text')))
student_name =(cgi.escape(self.request.get('student_name')))
student_email =(cgi.escape(self.request.get('student_email')))
sender_address= "Summit Tech Help <techhelpsummit@gmail.com>"
subject = "New Support Ticket!"
body= "test."
mail.send_mail(sender_address,sender_address,subject,body)
application = webapp2.WSGIApplication([
('/', ProblemRedirect),
], debug=True)
The commented line is what is causing the error. Any help would be appreciated! Thanks!
~Carpetfizz
I also tried adding:
http_headers:
Access-Control-Allow-Origin: "*"
to my app.yaml file, but I keep getting the error:
Error parsing yaml file:
Unexpected attribute "http_headers" for mapping type script.
in "/Users/ajay/summit-tech-help/app.yaml", line 13, column 1