2022-06-29 11:28:26 +02:00
{% extends "default.html" %}
2019-07-06 23:25:52 +02:00
{% set active_page = "dashboard" %}
2022-06-29 11:28:26 +02:00
{% block title %}Custom Alias{% endblock %}
2019-07-06 23:25:52 +02:00
{% block default_content %}
2022-06-29 11:28:26 +02:00
2020-05-11 23:22:06 +02:00
< div class = "card" >
< div class = "card-body" >
2020-12-31 14:15:25 +01:00
< h1 class = "h3" > New Custom Alias< / h1 >
2020-05-11 23:22:06 +02:00
{% if user_custom_domains|length == 0 and not DISABLE_ALIAS_SUFFIX %}
2022-06-29 11:28:26 +02:00
2020-05-11 23:22:06 +02:00
< div class = "row" >
< div class = "col p-1" >
< div class = "alert alert-primary" role = "alert" >
You might notice a random word after the dot(< em > .< / em > ) in the alias.
This part is to avoid a person taking all the "nice" aliases like
< b > hello@{{ FIRST_ALIAS_DOMAIN }}< / b > ,
2022-06-29 11:28:26 +02:00
< b > me@{{ FIRST_ALIAS_DOMAIN }}< / b > , etc.
< br / >
2024-01-03 12:35:42 +01:00
If you add your own domain (or subdomain), this restriction is removed, and you can fully customize the alias.
2022-06-29 11:28:26 +02:00
< br / >
2020-05-11 23:22:06 +02:00
< / div >
2020-02-18 05:59:03 +01:00
< / div >
< / div >
2020-05-11 23:22:06 +02:00
{% endif %}
2021-09-06 18:51:50 +02:00
< form method = "post" data-parsley-validate >
2020-05-11 23:22:06 +02:00
< div class = "row mb-2" >
< div class = "col-sm-6 mb-1 p-1" style = "min-width: 4em" >
2022-06-29 11:28:26 +02:00
< input name = "prefix"
class="form-control"
2020-05-16 11:28:25 +02:00
id="prefix"
2020-05-11 23:22:06 +02:00
type="text"
2021-09-06 18:51:50 +02:00
data-parsley-pattern="[0-9a-z-_.]{1,}"
data-parsley-trigger="change"
data-parsley-error-message="Only lowercase letters, dots, numbers, dashes (-) and underscores (_) are currently supported."
2020-11-18 10:38:35 +01:00
maxlength="40"
2021-04-30 11:37:17 +02:00
placeholder="Alias prefix, for example newsletter.com-123_xyz"
2022-06-29 11:28:26 +02:00
autofocus
required>
2020-02-18 05:54:35 +01:00
< / div >
2020-05-11 23:22:06 +02:00
< div class = "col-sm-6 p-1" >
2021-07-19 20:14:59 +02:00
< select class = "form-control" name = "signed-alias-suffix" >
2022-07-27 17:40:22 +02:00
{% for alias_suffix in alias_suffixes %}
2022-06-29 11:28:26 +02:00
2022-07-27 17:40:22 +02:00
< option value = "{{ alias_suffix.signed_suffix }}" { % if alias_suffix . is_premium % }
2022-06-29 11:28:26 +02:00
title="Only available to Premium accounts" {% elif not alias_suffix.is_custom and at_least_a_premium_domain %} title="Available to all accounts" {% endif %}>
2021-07-19 20:14:59 +02:00
{% if alias_suffix.is_custom %}
2021-12-28 12:01:32 +01:00
{% if alias_suffix.mx_verified %}
2022-06-29 11:28:26 +02:00
2021-12-28 12:01:32 +01:00
{{ alias_suffix.suffix }} (your domain)
{% else %}
{{ alias_suffix.suffix }} (your domain, not MX verified yet)
{% endif %}
2020-05-11 23:22:06 +02:00
{% else %}
2021-07-19 20:14:59 +02:00
{% if alias_suffix.is_premium %}
2022-06-29 11:28:26 +02:00
2021-07-19 20:14:59 +02:00
{{ alias_suffix.suffix }} (Premium domain)
2020-10-20 16:44:22 +02:00
{% else %}
2021-07-19 20:14:59 +02:00
{{ alias_suffix.suffix }} (Public domain)
2020-10-20 16:44:22 +02:00
{% endif %}
2020-05-11 23:22:06 +02:00
{% endif %}
< / option >
{% endfor %}
< / select >
2020-02-10 17:19:42 +01:00
< / div >
< / div >
2020-05-11 23:22:06 +02:00
< div class = "row mb-2" >
< div class = "col p-1" >
2020-05-16 12:17:26 +02:00
< select data-width = "100%"
2022-06-29 11:28:26 +02:00
class="mailbox-select"
id="mailboxes"
multiple
name="mailboxes"
required>
2020-05-11 23:22:06 +02:00
{% for mailbox in mailboxes %}
2022-06-29 11:28:26 +02:00
< option value = "{{ mailbox.id }}"
{% if mailbox.id == current_user.default_mailbox_id %} selected{% endif %}>
2020-05-16 11:28:25 +02:00
{{ mailbox.email }}
2020-05-11 23:22:06 +02:00
< / option >
{% endfor %}
< / select >
2022-06-29 11:28:26 +02:00
< div class = "small-text" > The mailbox(es) that owns this alias.< / div >
2020-02-10 17:19:42 +01:00
< / div >
2020-02-05 11:36:06 +01:00
< / div >
2020-05-11 23:22:06 +02:00
< div class = "row mb-2" >
< div class = "col p-1" >
2020-05-16 11:28:25 +02:00
< textarea name = "note"
class="form-control"
rows="3"
2020-05-27 22:52:45 +02:00
placeholder="Note, can be anything to help you remember why you created this alias. This field is optional.">< / textarea >
2020-05-11 23:22:06 +02:00
< / div >
2020-02-05 11:36:06 +01:00
< / div >
2020-05-11 23:22:06 +02:00
< div class = "row" >
< div class = "col p-1" >
2023-12-20 16:15:01 +01:00
{{ csrf_form.csrf_token }}
2021-08-16 18:07:40 +02:00
< button type = "submit" id = "create" class = "btn btn-primary mt-1" > Create< / button >
2020-05-11 23:22:06 +02:00
< / div >
2020-02-05 11:36:06 +01:00
< / div >
2020-05-11 23:22:06 +02:00
< / form >
< / div >
2019-07-06 23:25:52 +02:00
< / div >
{% endblock %}
2020-05-03 16:50:39 +02:00
{% block script %}
2022-06-29 11:28:26 +02:00
2020-05-03 16:50:39 +02:00
< script >
2020-05-16 12:17:26 +02:00
$('.mailbox-select').multipleSelect();
2021-12-28 12:01:32 +01:00
2021-01-16 19:56:30 +01:00
// Ctrl-enter submit the form
2021-12-28 12:01:32 +01:00
$('form').keydown(function (event) {
2021-01-16 19:56:30 +01:00
if (event.ctrlKey & & event.keyCode === 13) {
$("#submit").click();
}
})
2020-05-16 12:17:26 +02:00
2021-08-16 18:07:40 +02:00
$("#create").on("click", async function () {
2020-05-03 16:50:39 +02:00
let that = $(this);
let mailbox_ids = $(`#mailboxes`).val();
2020-05-10 15:21:31 +02:00
let prefix = $('#prefix').val();
2020-05-03 16:50:39 +02:00
if (mailbox_ids.length == 0) {
toastr.error("You must select at least a mailbox", "Error");
return;
}
2020-05-10 15:21:31 +02:00
if (!prefix) {
toastr.error("Alias cannot be empty", "Error");
return;
}
2020-05-03 16:50:39 +02:00
that.closest("form").submit();
})
2022-07-04 16:01:04 +02:00
< / script >
2020-05-03 16:50:39 +02:00
{% endblock %}