Guest User

Untitled

a guest
May 30th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. from django.shortcuts import render
  2. from .forms import AccountEmail, AccountPassword
  3. from django.http import HttpResponse
  4.  
  5. import imaplib
  6.  
  7.  
  8. username = ''
  9. password = ''
  10. def get_email(request):
  11. template = 'email_account/index.html'
  12. if request.method == 'POST':
  13. email_input = AccountEmail(request.POST)
  14. password_input = AccountPassword(request.POST)
  15. if email_input.is_valid():
  16. username = email_input.cleaned_data['email']
  17. if password_input.is_valid():
  18. password = password_input.cleaned_data['password']
  19. else:
  20. email_input = AccountEmail()
  21. password_input = AccountPassword()
  22.  
  23. return render(request,template,{'email': email_input, 'password': password_input})
  24.  
  25. def inbox(request):
  26. server = imaplib.IMAP4_SSL('imap.gmail.com')
  27. server.login(username, password)
  28. server.select('inbox')
  29. ch, data = server.search(None, 'all')
  30. mail_id = data[0]
  31. lst = mail_id.split()
  32. return render("<h2>lst</h2>")
  33.  
  34. from django import forms
  35.  
  36. class AccountEmail(forms.Form):
  37. email = forms.EmailField(max_length=50, widget=forms.TextInput(attrs={'placeholder': 'Introduce your email'}))
  38.  
  39. class AccountPassword(forms.Form):
  40. password = forms.CharField(max_length=20, widget=forms.TextInput(attrs={'placeholder': 'Introduce your password'}))
Add Comment
Please, Sign In to add comment