Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from .forms import AccountEmail, AccountPassword
- from django.http import HttpResponse
- import imaplib
- username = ''
- password = ''
- def get_email(request):
- template = 'email_account/index.html'
- if request.method == 'POST':
- email_input = AccountEmail(request.POST)
- password_input = AccountPassword(request.POST)
- if email_input.is_valid():
- username = email_input.cleaned_data['email']
- if password_input.is_valid():
- password = password_input.cleaned_data['password']
- else:
- email_input = AccountEmail()
- password_input = AccountPassword()
- return render(request,template,{'email': email_input, 'password': password_input})
- def inbox(request):
- server = imaplib.IMAP4_SSL('imap.gmail.com')
- server.login(username, password)
- server.select('inbox')
- ch, data = server.search(None, 'all')
- mail_id = data[0]
- lst = mail_id.split()
- return render("<h2>lst</h2>")
- from django import forms
- class AccountEmail(forms.Form):
- email = forms.EmailField(max_length=50, widget=forms.TextInput(attrs={'placeholder': 'Introduce your email'}))
- class AccountPassword(forms.Form):
- password = forms.CharField(max_length=20, widget=forms.TextInput(attrs={'placeholder': 'Introduce your password'}))
Add Comment
Please, Sign In to add comment