{% extends 'base.html' %}

{% block title %}
{{ address_name }} - Fake Email Server
{% endblock %}

{% block content %}


    {% if email_list %}
        <div id="nav">
        {% for message in email_list %}
            <a href='#{{ loop.index }}'>{{ loop.index }}</a>
        {% endfor %}
        </div>
    
        <table>
        <thead>
            <th>Msg ID</th>
            <th>Format</th>
            <th>Headers</th>
            <th>Content</th>
        </thead>
            {% for msg in email_list %}
                <tr>
                    <td><a name='{{ loop.index }}'>{{ loop.index }}</a></td>
                    <td>{{ msg['content_type'] }}</td>
                            <td class="headers">
                                {% for header in msg['headers'] %}
                                {{header[0]}} {{header[1]}} <br />
                                {% endfor %}
                            </td>
                            <td class="payload">
                                {{ msg['payload'] }}
                            </td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <pre>No emails recorded for this address</pre>
    {% endif %}
    

{% endblock %}
