-1

EDIT: In case you want to test i have deployed the code to this github repo

The basic feature i want to implement is sending mails from a form. Almost what anyother Contact Us form on your website does. The demo url is takemailer.appspot.com

The form as can be seen in url, sends a post request to the server. The views where i handle the request is as follows:

def post_data(request):   
    logging.info(request.POST)
    frm_name = request.POST['name']    frm_mail = request.POST['email']
    frm = frm_name + " <" + frm_mail + ">"
    frm = '"%s"' % frm #above two lines # done to produce a format like "Name <name@mail.com>"
    sub = request.POST['subject']
    cmnt = request.POST['comment']
    extra = str(frm + sub +  cmnt)  
    logging.info(frm)
    a = mail.send_mail(sender=frm,
              to="Albert Johnson <du***@gmail.com>",
              subject=sub,
              body=cmnt) 
    logging.info(a)
    return http.HttpResponse("1")

The above version of the code does not work and raises

<class 'django.core.exceptions.ImproperlyConfigured'>: You haven't set the DATABASE_ENGINE setting yet.

Stacktrace attached at bottom.

However if i modify the views function to hardcode a from email as shown below it works seamlessly:

def post_data(request):   
        logging.info(request.POST)
        sub = request.POST['subject']
        cmnt = request.POST['comment']
        a = mail.send_mail(sender="Albert Johnson <du***@gmail.com>",
                  to="Albert Johnson <du***@gmail.com>",
                  subject=sub,
                  body=cmnt) 
        logging.info(a)
        return http.HttpResponse("1")

Any idea of why the above is working and the one above this is not working, and raising such an error?

Stacktrace:

Traceback (most recent call last):
  File "/base/data/home/apps/s~takemailer/1.357442066172211834/django_bootstrap.py", line 65, in <module>
    main()
  File "/base/data/home/apps/s~takemailer/1.357442066172211834/django_bootstrap.py", line 62, in main
    util.run_wsgi_app(application)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app
    run_bare_wsgi_app(add_wsgi_middleware(application))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 116, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/core/handlers/wsgi.py", line 189, in __call__
    response = self.get_response(request)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/core/handlers/base.py", line 115, in get_response
    receivers = dispatcher.send(signal=signals.got_request_exception)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/dispatch/dispatcher.py", line 360, in send
    **named
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/dispatch/robustapply.py", line 47, in robustApply
    return receiver(*arguments, **named)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/db/__init__.py", line 47, in _rollback_on_exception
    transaction.rollback_unless_managed()
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/db/transaction.py", line 145, in rollback_unless_managed
    connection._rollback()
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/db/backends/dummy/base.py", line 13, in complain
    raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet."

this question is a follow up question from here since that question did not get any answer, i kept trying further, the problem has boiled down to this small measure:

Community
  • 1
  • 1
user993563
  • 18,601
  • 10
  • 42
  • 55
  • Answer is already there: "You haven't set the DATABASE_ENGINE setting yet." – PasteBT Mar 12 '12 at 18:51
  • yes i haveNOT, agreed, but why am i not seeing this error, when i hardcode email address?? second i tried setting database sqlite3 i get another error, i try dummy it works on local but 500 on server, i try 'appengine' but that again generates 500. – user993563 Mar 12 '12 at 19:07
  • I guess the error is not came from the code you post here. – PasteBT Mar 12 '12 at 20:35
  • 1
    It looks a little like your code is throwing some sort of exception, but the django exception handler ends up throwing a different (DATABASE_ENGINE) exception. Did you check that the "frm" value gets constructed properly as a string? You might need a space between the name and email address. – dragonx Mar 12 '12 at 20:50
  • The line `frm = '"%s"' % frm` seems dodgy and unnecessary. What happens if you remove it? – Daniel Roseman Mar 12 '12 at 21:01
  • you see this line `logging.info(frm)` i see what the output is, i have tried various other permutations as well. – user993563 Mar 13 '12 at 06:42
  • have pushed the code to a repo, in case any one is interested in testing. Thanks. – user993563 Mar 13 '12 at 07:01

1 Answers1

2

Well the error does not lie in code, it lies i google's policy :) When you read through it, through your app the one who can send email should have either:

  1. an email with same domain name.
  2. The admin of the app.

Hope you get your answer.

apcelent
  • 1,651
  • 12
  • 12