Django Registration with GMail account

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  if send_email:            
      current_domain = Site.objects.get_current().domain
      subject = "Activate your new account at %s" %  current_domain
      message_template = loader.get_template('registration/activation_email.txt')
      message_context = Context({ 'site_url': 'http://%s/' % current_domain,
                                        'activation_key': activation_key,
                                        'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS })
        message = message_template.render(message_context)
        ga = libgmail.GmailAccount(settings.GMAIL_USERNAME, settings.GMAIL_PASSWORD)
        ga.login()
        msg = libgmail.GmailComposedMessage(to=new_user.email, subject=subject, body=message)
        ga.sendMessage(msg)

More like this

  1. Django Registration without username by newmaniese 5 years, 2 months ago
  2. Using manager methods by ubernostrum 6 years, 3 months ago
  3. Simple E-mail registration by bthomas 4 years, 7 months ago
  4. Saving passwords for other services (semi-)securely in a database by equanimity 4 years, 4 months ago
  5. Reset / Send account details email by Ciantic 2 years, 10 months ago

Comments

sleepyguitar (on October 24, 2007):

some problems

NameError at /accounts/register/ global name 'activation_key' is not defined

Request Method: POST Request URL: http://www.atschool.com.cn:8000/accounts/register/ Exception Type: NameError Exception Value: global name 'activation_key' is not defined Exception Location: C:\Python25\lib\site-packages\registration\models.py in create_inactive_user, line 95 Python Executable: C:\Python25\python.exe Python Version: 2.5.1

#

oliver.andrich (on January 22, 2008):

Why is it neccessary to use libgmail? You could just activate the POP access to the gmail account and use the official SMTP server of googlemail.

Look at: http://www.djangoproject.com/documentation/email/

#

woot4moo (on April 27, 2008):

I am going to save everyone a lot of heart ache here. Add these lines and that error will go away:

in create_inactive_user(...)

salt = sha.new(str(random.random())).hexdigest()[:5] activation_key = sha.new(salt+new_user.username).hexdigest()

and change profile_callback to this: if profile_callback is not None: profile_callback(user=new_user, activiation_key=activiation_key)

#

asinox (on September 3, 2009):

oliver.andrich is right.

#

(Forgotten your password?)