Esempio n. 1
0
def mail_compose():
    if request.method == 'POST':
        content = request.form['content']
        if content:
            receiver = User.query.get(request.form['receiver'])
            subject = request.form['subject']
            mail = Mail(content=content,
                        subject=subject,
                        sender=g.user,
                        receiver=receiver)
            db.session.add(mail)
            db.session.commit()
            # generate automated Administrator response
            if receiver.id == 1:
                content = "I would be more than happy to help you with that. Unforunately, the person respsonsible for that is unavailable at the moment. We'll get back with you soon. Thanks."
                mail = Mail(content=content,
                            subject='RE:' + subject,
                            sender=receiver,
                            receiver=g.user)
                db.session.add(mail)
                db.session.commit()
            flash('Mail sent.')
            return redirect(url_for('ph_bp.mail'))
    users = User.query.filter(User.id != g.user.id).order_by(
        User.username.asc()).all()
    return render_template('mail_compose.html', users=users)
Esempio n. 2
0
 def post(self):
     user = str(users.get_current_user())
     besedilo = self.request.get("sporocilo")
     naslovnik = self.request.get("naslovnik")
     sporocilo = Mail(besedilo=besedilo, avtor=user, naslovnik=naslovnik)
     sporocilo.put()
     return self.redirect_to("poslji")
Esempio n. 3
0
 def _mail_check(self, mail_addr):
     "check mail exist or not and return mail object"
     t_sql = Mail.select().where(Mail.addr == mail_addr)
     if t_sql.count():
         return t_sql[0]
     else:
         return Mail.create(addr=mail_addr)
Esempio n. 4
0
def requestFriend():
    result = dict(
        type=ProtocolTypes.RequestFriend,
        result=ResultCodes.Success)

    if request.form['data']:
        got_data = json.loads(request.form['data'])

        from_keys = ['session_id', 'request_friend']
        if checkContainKeys(from_keys, got_data):
            result['result'], got_user = checkSessionId(got_data['session_id'])

            if got_user:
                find_friend = Friend.query.filter_by(user_id=got_user.id, friend_id=got_data['request_friend']).first()
                if not find_friend:
                    friend_data = Friend(got_user.id, got_data['request_friend'])
                    db_session.add(friend_data)
                    write_mail = Mail(got_user.id, got_data['request_friend'], u"친구 신청")
                    write_mail.request_friend = True
                    db_session.add(write_mail)
                    result['result'] = commitData()
                else:
                    result['result'] = ResultCodes.DataExist
        else:
            result['result'] = ResultCodes.InputParamError
    else:
        result['result'] = ResultCodes.AccessError

    return str(json.dumps(result))
Esempio n. 5
0
 def post(self):
     user = users.get_current_user()
     if user:
         posiljatelj = user.email().lower()
         naslovnik = self.request.get('naslovnik').replace('<script>', '').replace('</script>', '').lower()
         zadeva = self.request.get('zadeva').replace('<script>', '').replace('</script>', '')
         sporocilo = self.request.get('sporocilo').replace('<script>', '').replace('</script>', '')
         podatki = Mail(posiljatelj=posiljatelj, naslovnik=naslovnik, zadeva=zadeva, sporocilo=sporocilo, poslano=True)
         podatki.put()
         return self.redirect_to('poslano')
Esempio n. 6
0
def delete_mail(user, mail_id, domain=settings.MY_DOMAINS[0]):
	try:
		mail = list(Mail.select(AND(Mail.q.user==User.select(AND(User.q.name==user, Domain.q.name==domain))[0],
									Mail.q.id==mail_id)))[0]
	except IndexError:
		abort(404)
	#if divmod((datetime.datetime.now() - mail.ts).total_seconds(), 60)[0] > 10:
	if (datetime.datetime.now() - mail.ts) > datetime.timedelta(seconds=600):
		abort(403)
	Mail.delete(mail_id)
	return redirect(url_for('list_mail', user=user, domain=domain))
Esempio n. 7
0
    def post(self, request, *args, **kwargs):
        receiverId = User.objects.get_by_natural_key(
            request.POST['receiver']).userprofile

        mail = Mail()
        mail.from_user = self.request.user.userprofile
        mail.to_user = receiverId
        mail.title = request.POST['title']
        mail.content = request.POST['content']
        mail.create_time = datetime.now()
        mail.view = 0
        mail.save()
        return HttpResponseRedirect('.')
Esempio n. 8
0
def fetch_mail(request):
	"""docstring for fetch_mail"""
	p=poplib.POP3('pop3.163.com')
	p.user('airobot1')
	p.pass_('ragamuffin')
	count,size=p.stat()
	for i in range(count):
		hr,msg,oct=p.retr(i+1)
		mail=Mail()
		mail.RawData=string.join(msg,'\n')
		mail.save()
		p.dele(i+1)
	p.quit()
	return HttpResponseRedirect('/admin/')
Esempio n. 9
0
def delete_mail(user, mail_id, domain=settings.MY_DOMAINS[0]):
    try:
        mail = list(
            Mail.select(
                AND(
                    Mail.q.user == User.select(
                        AND(User.q.name == user, Domain.q.name == domain))[0],
                    Mail.q.id == mail_id)))[0]
    except IndexError:
        abort(404)
    #if divmod((datetime.datetime.now() - mail.ts).total_seconds(), 60)[0] > 10:
    if (datetime.datetime.now() - mail.ts) > datetime.timedelta(seconds=600):
        abort(403)
    Mail.delete(mail_id)
    return redirect(url_for('list_mail', user=user, domain=domain))
Esempio n. 10
0
    def post(self, request, *args, **kwargs):
            receiverId = User.objects.get_by_natural_key(request.POST['receiver']).userprofile

            mail = Mail()
            mail.from_user = self.request.user.userprofile
            mail.to_user = receiverId
            mail.title = request.POST['title']
            mail.content = request.POST['content']
            mail.create_time = datetime.now()
            mail.view = 0
            mail.save()
            return HttpResponseRedirect('.')
Esempio n. 11
0
    def post(self, mail_id):
        user = users.get_current_user()
        logout_url = users.create_logout_url('/')
        email_data = Mail.query(Mail.izbrisan == False).fetch()
        mail = Mail.get_by_id(int(mail_id))

        mail.izbrisan = True
        mail.put()

        params = {
            "logout_url": logout_url,
            "user": user,
            "email_data": email_data,
            "izbris": u"Sporočilo uspešno izbrisano"
        }
        return self.render_template("poslano.html", params=params)
Esempio n. 12
0
    def get(self, mail_id):
        user = users.get_current_user()
        logout_url = users.create_logout_url('/')
        mail = Mail.get_by_id(int(mail_id))

        params = {"logout_url": logout_url, "user": user, "mail_id": mail}
        return self.render_template("prejeto.html", params=params)
Esempio n. 13
0
def send_mail(header, content, to_email, from_email):
    data = {
        "personalizations": [
            {
            "to": [
                {
                "email": to_email
                }
            ],
            "subject": header
            }
        ],
        "from": {
            "email": from_email
        },
        "content": [
            {
            "type": "text/html",
            "value": content
            }
        ]
    }
    
    try:
        response = sg.client.mail.send.post(request_body=data)
        error = None
    except Exception as ex:
        error = str(ex)
    finally:
        mail = Mail(header, content, response.status_code, error, to_email, from_email)
        db.session.add(mail)
        db.session.commit()
Esempio n. 14
0
 def test_method_post_text(self):
     # attachments = []
     # attachments = self.get_attachments()
     mail = Mail(
         track_open=False,
         track_html_link=False,
         track_text_link=True,
         activate_tracking=False,
         subject='Mittepro-py client test',
         # send_at='2019-05-04 08:00:00',
         message_text=self.variables['message_text'],
         message_html=self.variables['message_html'],
         from_=self.variables['from_'],
         recipient_list=self.variables['recipients'],
         # context={'GMERGE': 'Mah oia Soh'},
         # context_per_recipient=self.variables['']
     )
     try:
         response = self.mittepro.send(mail)
         if response and 'emails_enviados' in response:
             self.assertGreater(len(response['emails_enviados']), 0)
         else:
             self.assertIsNotNone(response)
     except Exception as e:
         print("Exception", e)
Esempio n. 15
0
 def t2est_method_post_template(self):
     # attachments = []
     # attachments = self.get_attachments()
     mail = Mail(
         track_open=True,
         track_html_link=False,
         track_text_link=False,
         activate_tracking=True,
         subject='Mittepro-py client test',
         send_at='2019-05-04 08:00:00',
         from_=self.variables['from_'],
         recipient_list=self.variables['recipients'],
         template_slug='tpl-teste',
         use_tpl_default_name=True,
         use_tpl_default_email=True,
         use_tpl_default_subject=True,
         context={'GMERGE': 'Mah oia Soh'},
         context_per_recipient=self.variables['context_per_recipient'],
         # attachments=attachments
     )
     # print mail.get_payload()
     response = self.mittepro.send_template(mail)
     print("response", response)
     if response and 'emails_enviados' in response:
         self.assertGreater(len(response['emails_enviados']), 0)
     else:
         self.assertIsNotNone(response)
Esempio n. 16
0
    def post(self):
        user = users.get_current_user()

        od = self.request.get(utils.escape("od"))
        if len(od) == 0:
            od = user.email()
        do = self.request.get(utils.escape("do"))
        sporocilo = self.request.get(utils.escape("sporocilo"))
        usr_id = user.user_id()
        email = Mail(od=od, do=do, sporocilo=sporocilo, user_ID=usr_id)

        if email is not None:
            email.put()
            info = {"user": user, "uspeh": u"Sporočilo uspešno poslano"}

            return self.render_template("vremail.html", params=info)
Esempio n. 17
0
def register():
    if request.method == 'POST':
        username = request.form['username']
        if not User.query.filter_by(username=username).first():
            password = request.form['password']
            if password == request.form['confirm_password']:
                if is_valid_password(password):
                    user_dict = {}
                    for k in request.form:
                        if k not in ('confirm_password', ):
                            user_dict[k] = request.form[k]
                    user = User(**user_dict)
                    db.session.add(user)
                    db.session.commit()
                    # create default welcome message
                    sender = User.query.get(1)
                    receiver = user
                    subject = 'Welcome to PwnedHub!'
                    content = "We're glad you've chosen PwnedHub to help you take your next step in becoming a more efficient security consultant. We're here to help. If you have any questions or concerns, please don't hesitate to reach out to this account for assistance. Together, we can make seurity testing great again!"
                    mail = Mail(content=content,
                                subject=subject,
                                sender=sender,
                                receiver=receiver)
                    db.session.add(mail)
                    db.session.commit()
                    flash('Account created. Please log in.')
                    return redirect(url_for('ph_bp.login'))
                else:
                    flash('Password does not meet complexity requirements.')
            else:
                flash('Passwords do not match.')
        else:
            flash('Username already exists.')
    return render_template('register.html', questions=QUESTIONS)
Esempio n. 18
0
 def test_method_post_template(self):
     # attachments = []
     # attachments = self.get_attachments()
     mail = Mail(
         # headers={'X_CLIENT_ID': 1},
         recipient_list=self.variables['recipients'],
         # from_=self.variables['from_'],
         template_slug=self.variables['template_slug'],
         context={'foobar': True},
         context_per_recipient=self.variables['context_per_recipient'],
         subject="Just a test - Sended From Client AT 09",
         # remove comment if you gonna tested
         # message_text=self.variables["message_text"],
         # message_html=self.variables["message_html"],
         # use_tpl_default_subject=True,
         use_tpl_default_email=True,
         # use_tpl_default_name=True,
         # activate_tracking=True,
         # get_text_from_html=True,
         # attachments=attachments
     )
     # print mail.get_payload()
     response = self.mittepro.send_template(mail)
     print "response", response
     if response and 'emails_enviados' in response:
         self.assertGreater(len(response['emails_enviados']), 0)
     else:
         self.assertIsNotNone(response)
Esempio n. 19
0
    def post(self):
        zadeva = self.request.get("zadeva")
        vsebina = self.request.get("vsebina")
        email = self.request.get("email")
        zadeva = cgi.escape(zadeva)
        vsebina = cgi.escape(vsebina)
#patricija
        cookie_value = self.request.cookies.get("uid")
        idposiljatelja, _, _ = cookie_value.split(":")
        idposiljatelja = int(idposiljatelja)
        prejemnik = Uporabnik.gql("WHERE email='"+ email +"'").get()
        idprejemnika = prejemnik.key.id()
        sporocilo = Mail(idprejemnika=idprejemnika, idposiljatelja=idposiljatelja, email=email,zadeva=zadeva, vsebina=vsebina)
        sporocilo.put()

        self.redirect("prikazi_vsa_sporocila.html")
Esempio n. 20
0
 def test_method_post_text(self):
     # attachments = []
     # attachments = self.get_attachments()
     mail = Mail(
         recipient_list=self.variables['recipients'],
         message_text='Mah oia só https://pypi.org/',
         # remove comment if you gonna tested
         # message_html=self.variables["message_html"],
         from_=self.variables['from_'],
         # batchs=self.variables['batchs'],
         # time_between_batchs=self.variables['time_between_batchs'],
         subject="Just a test - Sended From_ Client AT 09",
         send_at='2018-11-16 10:45',
         # send_at='2018-02-05 09:32:00',
         activate_tracking=False,
         track_open=False,
         track_html_link=False,
         track_text_link=False,
         # attachments=attachments
     )
     response = self.mittepro.send(mail)
     print "response", response
     if response and 'emails_enviados' in response:
         self.assertGreater(len(response['emails_enviados']), 0)
     else:
         self.assertIsNotNone(response)
Esempio n. 21
0
    def eomReceived(self):
        header = ""
        header_done = False
        message = ""
        for line in self.lines:
            if header_done:
                message += line + "\r\n"
                continue
            if line == "":
                header_done = True
                continue
            header += line + "\r\n"
            thisHeader = line.split(": ", 1)
        headers = Parser().parsestr(header)
        self.lines = None

        connect()
        domain = get_or_create_domain(self.user.dest.domain)
        user = get_or_create_user(self.user.dest.local, domain)
        Mail(user=user,
             ts=datetime.datetime.now(),
             envelopeHeloHost=self.user.helo[0],
             envelopeHeloAddress=self.user.helo[1],
             envelopeFrom=str(self.user.orig),
             envelopeTo=str(self.user.dest),
             headerFrom=headers["from"] or "",
             headerSubject=headers["subject"] or "",
             headers=header,
             body=message)

        return defer.succeed(None)
Esempio n. 22
0
    def get(self):
        vsa_sporocila = Mail.query().order(Mail.ustvarjeno).fetch()

        view_vars = {
            "vsa_sporocila": vsa_sporocila
        }

        self.render_template("prikazi_vsa_sporocila.html", view_vars)
Esempio n. 23
0
    def post(self, sporocilo_id):
        sporocilo = Mail.get_by_id(int(sporocilo_id))
        sporocilo.zadeva = self.request.get("zadeva")
        sporocilo.vsebina = int(self.request.get("vsebina"))
        sporocilo.idprejemnika = self.request.get("idprejemnika")
        sporocilo.put()

        self.redirect("/sporocilo/" + int(sporocilo_id))
Esempio n. 24
0
    def get(self, sporocilo_id):
        sporocilo = Mail.get_by_id(int(sporocilo_id))

        view_vars = {
            "sporocilo": sporocilo
        }

        self.render_template("izbrisi_sporocilo.html", view_vars)
Esempio n. 25
0
def list_mail(user, domain=settings.MY_DOMAINS[0]):
    try:
        mails = list(
            Mail.select(Mail.q.user == User.select(
                AND(User.q.name == user, Domain.q.name == domain))[0]))
    except IndexError:
        mails = []
    return render_template('list_mail.html', **locals())
Esempio n. 26
0
    def get(self):
        user = users.get_current_user()
        logout_url = users.create_logout_url('/')

        usr_mail = user.email()
        email_check = Mail.query().fetch(projection=[Mail.od])

        if email_check == usr_mail:
            email_data = Mail.query().fetch()
            params = {
                "logout_url": logout_url,
                "user": user,
                "email_data": email_data
            }
            return self.render_template("vremail.html", params=params)
        else:
            params = {"logout_url": logout_url, "user": user}
            return self.render_template("vremail.html", params=params)
Esempio n. 27
0
def getmail(address=None):
    lastmail = Mail.get_by_to(address)
    if lastmail is not None:
        if lastmail.content_type == 'text/html':
            return render_template('mail.html', mail=lastmail)
        else:
            return render_template('mail.txt', mail=lastmail)
    else:
        return 'No data found'
Esempio n. 28
0
    def post(self):
        to_users = self.request.get('to_users')
        to_emails = self.request.get('to')
        subject = self.request.get('subject')
        body = self.request.get('body')

        mail = Mail()
        mail.is_active = False
        mail.subject = subject
        mail.body = body
        mail.to_users = to_users
        mail.to_emails = split_emails(to_emails)
        mail.put()

        self.response.out.write(mail.to_json('subject', 'is_deleted', 'is_active', 'is_starred'))
Esempio n. 29
0
    def get(self):
        user = users.get_current_user()
        logout_url = users.create_logout_url('/')
        email_data = Mail.query(Mail.izbrisan == False).fetch()

        params = {
            "logout_url": logout_url,
            "user": user,
            "email_data": email_data
        }
        return self.render_template("poslano.html", params=params)
Esempio n. 30
0
def show_mail(user, mail_id, domain=settings.MY_DOMAINS[0]):
	try:
		mail = list(Mail.select(AND(Mail.q.user==User.select(AND(User.q.name==user, Domain.q.name==domain))[0],
									Mail.q.id==mail_id)))[0]
	except IndexError:
		abort(404)
	new_mail = False
	#if divmod((datetime.datetime.now() - mail.ts).total_seconds(), 60)[0] <= 10:
	if (datetime.datetime.now() - mail.ts) <= datetime.timedelta(seconds=600):
		new_mail = True
	mail_content = unicode(quopri.decodestring(mail.headers+"\r\n"+mail.body), 'utf-8', errors='ignore')
	return render_template('show_mail.html', **locals())
Esempio n. 31
0
 def get(self):
     user = users.get_current_user()
     if user:
         logiran = True
         logout_url = users.create_logout_url('/')
         params = {"logiran": logiran, "logout_url": logout_url, "user": user}
     else:
         logiran = False
         login_url = users.create_login_url('/')
         params = {"logiran": logiran, "login_url": login_url, "user": user}
     sporocila = Mail.query(Mail.izbrisano == True).fetch()
     podatki = {'sporocila': sporocila}
     podatki.update(params)
     return self.render_template("izbrisano.html",params=podatki)
Esempio n. 32
0
def mail_compose(id=0):
    if request.method == 'POST':
        content = request.form['content']
        if content:
            receiver = User.query.get(request.form['receiver'])
            subject = request.form['subject']
            mail = Mail(content=content,
                        subject=subject,
                        sender=g.user,
                        receiver=receiver)
            db.session.add(mail)
            db.session.commit()
            flash('Mail sent.')
            return redirect(url_for('mail'))
    users = User.query.filter(User.id == id).all() or User.query.filter(
        User.id != g.user.id).order_by(User.username.asc()).all()
    return render_template('mail_compose.html', users=users)
def convert_to_model(parsed_mail):
    mail = Mail()
    mail.message_id = parsed_mail.message_id
    mail.body = parsed_mail.body
    mail.subject = parsed_mail.subject
    mail.date = parsed_mail.date
    for recipient in recipients_from_list_of_tuples(parsed_mail.to,
                                                    parsed_mail.cc,
                                                    parsed_mail.bcc):
        mail.to.add(recipient)
    mail.sender.add(recipient_from_tuple(parsed_mail.from_[0]))
    return mail
Esempio n. 34
0
    def post(self):
      body = self.check_body([
          'name',
          'email',
          'message'
      ])
      try:
        mail.send_mail(sender="*****@*****.**",
                       to=body['email'],
                       subject='New Contact Message',
                       body=body['message'])

        mail_id = Mail.create(name=body['name'],
                              email=body['email'],
                              message=body['message'])
        self.response.out.write(mail_id)
      except ValueError as e:
        self.abort(code=404, detail=e.message)
Esempio n. 35
0
 def get_messages(self) -> List[ElementMail]:
     for el in self._browser.find_by_css_selector(
             'article.message.hasSender', True):
         el.click()
         [sender_el] = el.find_by_css_selector(
             'div.summary > div.summary-left > div.meta > div > div.from-value',
             True)
         [body_el
          ] = el.find_by_css_selector('div.frame.message-frame > div', True)
         [username_el] = sender_el.find_by_tag('strong')
         [email_el] = sender_el.find_by_tag('em')
         yield ElementMail(
             element=el,
             mail=Mail(sender=UserInfo(
                 username=username_el.text.replace('<',
                                                   '').replace('>', ''),
                 email=email_el.text.replace('<', '').replace('>', '')),
                       body=Body(body_el.text)))
Esempio n. 36
0
    def get(self, sporocilo_id):
        user = users.get_current_user()
        if user:
            logiran = True
            logout_url = users.create_logout_url('/')
            params = {"logiran": logiran, "logout_url": logout_url, "user": user}
        else:
            logiran = False
            login_url = users.create_login_url('/')
            params = {"logiran": logiran, "login_url": login_url, "user": user}

        sporocilo = Mail.get_by_id(int(sporocilo_id))
        sporocilo.prebrano = True
        sporocilo.put()

        podatki = {'sporocilo': sporocilo}
        podatki.update(params)
        return self.render_template("preberi.html",params=podatki)
Esempio n. 37
0
def show_mail(user, mail_id, domain=settings.MY_DOMAINS[0]):
    try:
        mail = list(
            Mail.select(
                AND(
                    Mail.q.user == User.select(
                        AND(User.q.name == user, Domain.q.name == domain))[0],
                    Mail.q.id == mail_id)))[0]
    except IndexError:
        abort(404)
    new_mail = False
    #if divmod((datetime.datetime.now() - mail.ts).total_seconds(), 60)[0] <= 10:
    if (datetime.datetime.now() - mail.ts) <= datetime.timedelta(seconds=600):
        new_mail = True
    mail_content = unicode(quopri.decodestring(mail.headers + "\r\n" +
                                               mail.body),
                           'utf-8',
                           errors='ignore')
    return render_template('show_mail.html', **locals())
Esempio n. 38
0
    def post(self, sporocilo_id):
        sporocilo = Mail.get_by_id(int(sporocilo_id))
        sporocilo.key.delete()

        self.redirect("prikazi_vsa_sporocila.html")
Esempio n. 39
0
 def get(self):
     mails = Mail.get_all()
     mails_list = []
     for mail in mails:
         mails_list.append(mail.to_json_dict('subject', 'is_starred', 'is_active', 'is_deleted', 'when_created', 'when_modified'))
     self.response.out.write(json.dumps(mails_list))
    def receive(self, mail_message):
        logging.info("Received a message from: " + mail_message.sender)
        # logging.debug(dir(mail_message))
        # ['ALLOWED_EMPTY_PROPERTIES', 'ALLOW_BLANK_EMAIL', 'CheckInitialized', 'Initialize', 'IsInitialized', 'PROPERTIES', 'Send', 'ToMIMEMessage', 'ToProto', '_API_CALL', '_EmailMessageBase__original', '_InboundEmailMessage__HEADER_PROPERTIES', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_add_body', '_check_attachment', '_check_attachments', '_update_payload', 'bodies', 'body', 'check_initialized', 'date', 'html', 'initialize', 'is_initialized', 'original', 'send', 'sender', 'subject', 'to', 'to_mime_message', 'update_from_mime_message']
        #logging.debug(dir(mail_message.original))
        #logging.debug(type(mail_message.original.as_string()))

        plaintext_bodies = mail_message.bodies('text/plain')
        html_bodies = mail_message.bodies('text/html')

        for content_type, body in html_bodies:
            logging.debug(body.decode())
            mail = Mail()
            mail.sender = mail_message.sender
            mail.to = mail_message.to
            mail.subject = mail_message.subject
            mail.body = body.decode()
            mail.content_type = content_type
            mail.original = mail_message.original.as_string()
            mail.put()

        for content_type, body in html_bodies:
            logging.debug(body.decode())
            mail = Mail()
            mail.sender = mail_message.sender
            mail.to = mail_message.to
            mail.subject = mail_message.subject
            mail.body = body.decode()
            mail.content_type = content_type
            mail.original = mail_message.original.as_string()
            mail.put()
Esempio n. 41
0
def list_mail(user, domain=settings.MY_DOMAINS[0]):
	try:
		mails = list(Mail.select(Mail.q.user==User.select(AND(User.q.name==user, Domain.q.name==domain))[0]))
	except IndexError:
		mails = []
	return render_template('list_mail.html', **locals())