python - Debugging 500 on incoming Mail on Heroku from Mailgun -


i'm trying debug view gets incoming mail mailgun django installation on heroku.

the view directly taken mailgun docs , if manually call url ok response.

@csrf_exempt def askfriend_emailresponse(request):     from_email = "..."     to_email = "..."     if request.method == 'post':         sender    = request.post.get('sender')         recipient = request.post.get('recipient')         answer = request.post.get('stripped-text', '')          try:             send_mail("inside post"+str(recipient[recipient.find("+")+1:recipient.find("@")]), answer, from_email, to_email)         except exception, e:             raise e      return httpresponse('ok') 

also, if place post url through external tool (i'm using poster purpose) can 200 (i had add @csrf_exempt that's fine now).

however, mailgun logs see there 500 error when forwarding message , heroku see there incoming request causing 500:

2013-03-13t09:59:04+00:00 heroku[router]: at=info method=post path=[url] host=[hostname].herokuapp.com fwd="198.61.253.112" dyno=web.1 queue=0 wait=0ms connect=1ms service=86ms status=500 bytes=102194 

my questions after spending more day researching:

1) idea wrong (would nice) - , @ least important

2) how can test this? because mailguns logs brief (500 - that's it!) , heroku doesn't there... also, having deploy heroku first quite slow, hence, i'm wondering if "smart" way develop... (all other things test locally external e-mail coming through post through mailgun don't know how test locally)

thanks!

i figured out problem was:

1) in mailgun tutorial, route create doesn't have '/' @ end (example is: http://myhost.com/messages) - however, append_slash caused problems post redirect then. solution append ''/' @ end redirect

2) (potential further issue later in production) - note in django 1.5 allowed_host value introduced restricts domains allowed make post requests. believe used in production environments (debug = false) cause problems later make sure set these accordingly (i believe allow mailgun.org host).

thanks tried out!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -