2014-08-17 22:43:57 +00:00
< style >
#alias_table .actions > * { padding-right: 3px; }
2021-09-18 23:23:31 +00:00
#alias_table .alias-auto .actions > * { display: none }
2014-08-17 22:43:57 +00:00
< / style >
< h2 > Aliases< / h2 >
< h3 > Add a mail alias< / h3 >
2023-05-13 10:49:34 +00:00
< p > Aliases are email forwarders. An alias can forward email to a < a href = "#users" > mail user< / a > or to any email address.< / p >
2014-08-17 22:43:57 +00:00
2015-08-14 23:05:08 +00:00
< p > To use an alias or any address besides your own login username in outbound mail, the sending user must be included as a permitted sender for the alias.< / p >
< form id = "addalias-form" class = "form-horizontal" role = "form" onsubmit = "do_add_alias(); return false;" >
2014-08-17 22:43:57 +00:00
< div class = "form-group" >
2014-09-27 12:08:25 +00:00
< div class = "col-sm-offset-1 col-sm-11" >
< div id = "alias_type_buttons" class = "btn-group btn-group-xs" >
2015-06-27 17:23:15 +00:00
< button type = "button" class = "btn btn-default" data-mode = "regular" > Regular< / button >
2014-11-14 13:33:12 +00:00
< button type = "button" class = "btn btn-default" data-mode = "catchall" > Catch-All< / button >
< button type = "button" class = "btn btn-default" data-mode = "domainalias" > Domain Alias< / button >
< / div >
< div id = "alias_mode_info" class = "text-info small" style = "display: none; margin: .5em 0 0 0;" >
2015-08-14 23:05:08 +00:00
< span class = "catchall hidden" > A catch-all alias captures all otherwise unmatched email to a domain.< / span >
< span class = "domainalias hidden" > A domain alias forwards all otherwise unmatched email from one domain to another domain, preserving the part before the @-sign.< / span >
2014-09-27 12:08:25 +00:00
< / div >
< / div >
< / div >
< div class = "form-group" >
2015-07-04 20:48:35 +00:00
< label for = "addaliasAddress" class = "col-sm-1 control-label" > Alias< / label >
2014-08-17 22:43:57 +00:00
< div class = "col-sm-10" >
2015-07-04 20:48:35 +00:00
< input type = "email" class = "form-control" id = "addaliasAddress" >
2015-08-14 23:05:08 +00:00
< div style = "margin-top: 3px; padding-left: 3px; font-size: 90%" class = "text-muted" >
< span class = "catchall domainalias" > Enter just the part of an email address starting with the @-sign.< / span >
You may use international (non-ASCII) characters for the domain part of the email address only.
< / div >
2014-08-17 22:43:57 +00:00
< / div >
< / div >
< div class = "form-group" >
2015-08-14 23:05:08 +00:00
< label for = "addaliasForwardsTo" class = "col-sm-1 control-label" > Forwards To< / label >
2014-08-17 22:43:57 +00:00
< div class = "col-sm-10" >
2015-08-14 23:05:08 +00:00
< textarea class = "form-control" rows = "3" id = "addaliasForwardsTo" > < / textarea >
2018-11-30 15:36:19 +00:00
< div style = "margin-top: 3px; padding-left: 3px; font-size: 90%" >
< span class = "domainalias text-muted" > Enter just the part of an email address starting with the @-sign.< / span >
< span class = "text-danger" > Only forward mail to addresses handled by this Mail-in-a-Box, since mail forwarded by aliases to other domains may be rejected or filtered by the receiver. To forward mail to other domains, create a mail user and then log into webmail for the user and create a filter rule to forward mail.< / span >
2015-08-14 23:05:08 +00:00
< / div >
2015-06-27 17:23:15 +00:00
< / div >
< / div >
2014-08-17 22:43:57 +00:00
< div class = "form-group" >
2015-07-04 15:31:11 +00:00
< label for = "addaliasSenders" class = "col-sm-1 control-label" > Permitted Senders< / label >
2014-08-17 22:43:57 +00:00
< div class = "col-sm-10" >
2015-08-14 23:05:08 +00:00
< div class = "radio" >
< label >
< input id = "addaliasForwardsToNotAdvanced" name = "addaliasForwardsToDivToggle" type = "radio" checked onclick = "$('#addaliasForwardsToDiv').toggle(false)" >
2019-02-12 01:14:56 +00:00
Any mail user listed in the Forwards To box can send mail claiming to be from < span class = "regularalias" > the alias address< / span > < span class = "catchall domainalias" > any address on the alias domain< / span > .
2015-08-14 23:05:08 +00:00
< / label >
< / div >
< div class = "radio" >
< label >
< input id = "addaliasForwardsToAdvanced" name = "addaliasForwardsToDivToggle" type = "radio" id = "addaliasForwardsToDivShower" onclick = "$('#addaliasForwardsToDiv').toggle(true)" >
I’ ll enter the mail users that can send mail claiming to be from < span class = "regularalias" > the alias address< / span > < span class = "catchall domainalias" > any address on the alias domain< / span > .
< / label >
< / div >
< div id = "addaliasForwardsToDiv" style = "margin-top: .5em; margin-left: 1.4em; display: none;" >
< textarea class = "form-control" rows = "3" id = "addaliasSenders" placeholder = "one user per line or separated by commas" > < / textarea >
< / div >
2014-08-17 22:43:57 +00:00
< / div >
< / div >
< div class = "form-group" >
2014-09-27 12:08:25 +00:00
< div class = "col-sm-offset-1 col-sm-11" >
< button id = "add-alias-button" type = "submit" class = "btn btn-primary" > Add Alias< / button >
2014-08-17 22:43:57 +00:00
< button id = "alias-cancel" class = "btn btn-default hidden" onclick = "aliases_reset_form(); return false;" > Cancel< / button >
< / div >
< / div >
< / form >
< h3 > Existing mail aliases< / h3 >
< table id = "alias_table" class = "table" style = "width: auto" >
< thead >
< tr >
< th > < / th >
2014-09-27 12:08:25 +00:00
< th > Alias< br > < / th >
2014-08-17 22:43:57 +00:00
< th > Forwards To< / th >
2015-07-04 15:31:11 +00:00
< th > Permitted Senders< / th >
2014-08-17 22:43:57 +00:00
< / tr >
< / thead >
< tbody >
< / tbody >
< / table >
2015-11-23 14:12:33 +00:00
< p style = "margin-top: 1.5em" > < small > hostmaster@, postmaster@, admin@ and abuse@ email addresses are required on some domains.< / small > < / p >
2014-08-17 22:43:57 +00:00
< div style = "display: none" >
< table >
< tr id = "alias-template" >
< td class = 'actions' >
2014-10-11 19:52:00 +00:00
< a href = "#" onclick = "aliases_edit(this); scroll_top(); return false;" class = 'edit' title = "Edit Alias" >
2014-08-17 22:43:57 +00:00
< span class = "glyphicon glyphicon-pencil" > < / span >
< / a >
< a href = "#" onclick = "aliases_remove(this); return false;" class = 'remove' title = "Remove Alias" >
< span class = "glyphicon glyphicon-trash" > < / span >
< / a >
< / td >
2015-07-04 20:48:35 +00:00
< td class = 'address' > < / td >
2015-08-14 23:05:08 +00:00
< td class = 'forwardsTo' > < / td >
2015-07-04 15:31:11 +00:00
< td class = 'senders' > < / td >
2014-08-17 22:43:57 +00:00
< / tr >
< / table >
< / div >
2016-08-08 11:28:10 +00:00
< h3 > Mail aliases API (advanced)< / h3 >
2016-06-29 11:34:54 +00:00
2016-08-08 11:28:10 +00:00
< p > Use your box’ s mail aliases API to add and remove mail aliases from the command-line or custom services you build.< / p >
2016-06-29 11:34:54 +00:00
< p > Usage:< / p >
2016-08-08 11:28:10 +00:00
< pre > curl -X < b > VERB< / b > [-d "< b > parameters< / b > "] --user {email}:{password} https://{{hostname}}/admin/mail/aliases[< b > action< / b > ]< / pre >
2016-06-29 11:34:54 +00:00
2016-08-08 11:28:10 +00:00
< p > Brackets denote an optional argument. Please note that the POST body < code > parameters< / code > must be URL-encoded.< / p >
2016-06-29 11:34:54 +00:00
2016-08-08 11:28:10 +00:00
< p > The email and password given to the < code > --user< / code > option must be an administrative user on this system.< / p >
2016-06-29 11:34:54 +00:00
2016-08-08 11:28:10 +00:00
< h4 style = "margin-bottom: 0" > Verbs< / h4 >
< table class = "table" style = "margin-top: .5em" >
2016-06-29 11:34:54 +00:00
< thead > < th > Verb< / th > < th > Action< / th > < th > < / th > < / thead >
2016-08-08 11:28:10 +00:00
< tr > < td > GET< / td > < td > < i > (none)< / i > < / td > < td > Returns a list of existing mail aliases. Adding < code > ?format=json< / code > to the URL will give JSON-encoded results.< / td > < / tr >
2016-09-23 19:11:37 +00:00
< tr > < td > POST< / td > < td > /add< / td > < td > Adds a new mail alias. Required POST-body parameters are < code > address< / code > and < code > forwards_to< / code > .< / td > < / tr >
2016-08-08 11:28:10 +00:00
< tr > < td > POST< / td > < td > /remove< / td > < td > Removes a mail alias. Required POST-body parameter is < code > address< / code > .< / td > < / tr >
2016-06-29 11:34:54 +00:00
< / table >
< h4 > Examples:< / h4 >
< p > Try these examples. For simplicity the examples omit the < code > --user me@mydomain.com:yourpassword< / code > command line argument which you must fill in with your email address and password.< / p >
2016-08-08 11:28:10 +00:00
< pre > # Gives a JSON-encoded list of all mail aliases
curl -X GET https://{{hostname}}/admin/mail/aliases?format=json
2016-06-29 11:34:54 +00:00
2016-08-08 11:28:10 +00:00
# Adds a new alias
2016-09-23 19:11:37 +00:00
curl -X POST -d "address=new_alias@mydomail.com" -d "forwards_to=my_email@mydomain.com" https://{{hostname}}/admin/mail/aliases/add
2016-06-29 11:34:54 +00:00
2016-08-08 11:28:10 +00:00
# Removes an alias
2016-06-29 11:34:54 +00:00
curl -X POST -d "address=new_alias@mydomail.com" https://{{hostname}}/admin/mail/aliases/remove
< / pre >
2014-08-17 22:43:57 +00:00
< script >
function show_aliases() {
$('#alias_table tbody').html("< tr > < td colspan = '2' class = 'text-muted' > Loading...< / td > < / tr > ")
api(
"/mail/aliases",
"GET",
{ format: 'json' },
function(r) {
$('#alias_table tbody').html("");
for (var i = 0; i < r.length ; i + + ) {
2021-02-28 14:35:40 +00:00
var hdr = $("< tr > < th colspan = '4' style = 'background-color: #EEE' > < / th > < / tr > ");
hdr.find('th').text(r[i].domain);
2014-10-07 19:47:30 +00:00
$('#alias_table tbody').append(hdr);
2014-08-17 22:43:57 +00:00
2014-10-07 19:47:30 +00:00
for (var k = 0; k < r [ i ] . aliases . length ; k + + ) {
var alias = r[i].aliases[k];
var n = $("#alias-template").clone();
n.attr('id', '');
2021-09-18 23:23:31 +00:00
if (alias.auto) n.addClass('alias-auto');
2015-07-04 20:48:35 +00:00
n.attr('data-address', alias.address_display); // this is decoded from IDNA, but will get re-coded to IDNA on the backend
n.find('td.address').text(alias.address_display)
2015-08-14 23:05:08 +00:00
for (var j = 0; j < alias.forwards_to.length ; j + + )
n.find('td.forwardsTo').append($("< div > < / div > ").text(alias.forwards_to[j]))
for (var j = 0; j < (alias.permitted_senders ? alias.permitted_senders.length : 0); j++)
n.find('td.senders').append($("< div > < / div > ").text(alias.permitted_senders[j]))
2014-10-07 19:47:30 +00:00
$('#alias_table tbody').append(n);
}
2014-08-17 22:43:57 +00:00
}
})
2014-09-27 12:08:25 +00:00
$(function() {
$('#alias_type_buttons button').off('click').click(function() {
$('#alias_type_buttons button').removeClass('active');
$(this).addClass('active');
2015-08-14 23:05:08 +00:00
$('#addalias-form .regularalias, #addalias-form .catchall, #addalias-form .domainalias').addClass('hidden');
2014-11-14 13:33:12 +00:00
if ($(this).attr('data-mode') == "regular") {
2015-07-04 20:48:35 +00:00
$('#addaliasAddress').attr('type', 'email');
2015-08-14 23:05:08 +00:00
$('#addaliasAddress').attr('placeholder', 'you@yourdomain.com (incoming email address)');
$('#addaliasForwardsTo').attr('placeholder', 'one address per line or separated by commas');
2014-11-14 13:33:12 +00:00
$('#alias_mode_info').slideUp();
2015-08-14 23:05:08 +00:00
$('#addalias-form .regularalias').removeClass('hidden');
2014-11-14 13:33:12 +00:00
} else if ($(this).attr('data-mode') == "catchall") {
2015-07-04 20:48:35 +00:00
$('#addaliasAddress').attr('type', 'text');
2015-08-14 23:05:08 +00:00
$('#addaliasAddress').attr('placeholder', '@yourdomain.com (incoming catch-all domain)');
$('#addaliasForwardsTo').attr('placeholder', 'one address per line or separated by commas');
2014-11-14 13:33:12 +00:00
$('#alias_mode_info').slideDown();
2015-08-14 23:05:08 +00:00
$('#addalias-form .catchall').removeClass('hidden');
2014-11-14 13:33:12 +00:00
} else if ($(this).attr('data-mode') == "domainalias") {
2015-07-04 20:48:35 +00:00
$('#addaliasAddress').attr('type', 'text');
2015-08-14 23:05:08 +00:00
$('#addaliasAddress').attr('placeholder', '@yourdomain.com (incoming catch-all domain)');
$('#addaliasForwardsTo').attr('placeholder', '@otherdomain.com (forward to other domain)');
2014-11-14 13:33:12 +00:00
$('#alias_mode_info').slideDown();
2015-08-14 23:05:08 +00:00
$('#addalias-form .domainalias').removeClass('hidden');
2014-09-27 12:08:25 +00:00
}
})
2014-11-14 13:33:12 +00:00
$('#alias_type_buttons button[data-mode="regular"]').click(); // init
2014-09-27 12:08:25 +00:00
})
2014-08-17 22:43:57 +00:00
}
var is_alias_add_update = false;
function do_add_alias() {
var title = (!is_alias_add_update) ? "Add Alias" : "Update Alias";
2015-07-04 20:48:35 +00:00
var form_address = $("#addaliasAddress").val();
2015-08-14 23:05:08 +00:00
var form_forwardsto = $("#addaliasForwardsTo").val();
var form_senders = ($('#addaliasForwardsToAdvanced').prop('checked') ? $("#addaliasSenders").val() : '');
if ($('#addaliasForwardsToAdvanced').prop('checked') & & !/\S/.exec($("#addaliasSenders").val())) {
show_modal_error(title, "You did not enter any permitted senders.");
return false;
}
2014-08-17 22:43:57 +00:00
api(
"/mail/aliases/add",
"POST",
{
update_if_exists: is_alias_add_update ? '1' : '0',
2015-07-04 15:31:11 +00:00
address: form_address,
2015-08-14 23:05:08 +00:00
forwards_to: form_forwardsto,
permitted_senders: form_senders
2014-08-17 22:43:57 +00:00
},
function(r) {
// Responses are multiple lines of pre-formatted text.
show_modal_error(title, $("< pre / > ").text(r));
show_aliases()
aliases_reset_form();
},
function(r) {
show_modal_error(title, r);
});
return false;
}
function aliases_reset_form() {
2015-07-04 20:48:35 +00:00
$("#addaliasAddress").prop('disabled', false);
$("#addaliasAddress").val('')
2015-08-14 23:05:08 +00:00
$("#addaliasForwardsTo").val('')
2015-07-04 15:31:11 +00:00
$("#addaliasSenders").val('')
2014-08-17 22:43:57 +00:00
$('#alias-cancel').addClass('hidden');
2014-09-27 12:08:25 +00:00
$('#add-alias-button').text('Add Alias');
2014-08-17 22:43:57 +00:00
is_alias_add_update = false;
}
function aliases_edit(elem) {
2015-07-04 20:48:35 +00:00
var address = $(elem).parents('tr').attr('data-address');
2015-08-14 23:05:08 +00:00
var receiverdivs = $(elem).parents('tr').find('.forwardsTo div');
2015-07-04 15:31:11 +00:00
var senderdivs = $(elem).parents('tr').find('.senders div');
2015-08-14 23:05:08 +00:00
var forwardsTo = "";
2015-07-04 15:31:11 +00:00
for (var i = 0; i < receiverdivs.length ; i + + )
2015-08-14 23:05:08 +00:00
forwardsTo += $(receiverdivs[i]).text() + "\n";
2015-07-04 15:31:11 +00:00
var senders = "";
for (var i = 0; i < senderdivs.length ; i + + )
senders += $(senderdivs[i]).text() + "\n";
2015-08-14 23:05:08 +00:00
if (address.charAt(0) == '@' & & forwardsTo.charAt(0) == '@')
2014-11-14 13:33:12 +00:00
$('#alias_type_buttons button[data-mode="domainalias"]').click();
2015-07-04 20:48:35 +00:00
else if (address.charAt(0) == '@')
2014-11-14 13:33:12 +00:00
$('#alias_type_buttons button[data-mode="catchall"]').click();
else
$('#alias_type_buttons button[data-mode="regular"]').click();
2015-06-27 17:23:15 +00:00
$('#alias-cancel').removeClass('hidden');
2015-07-04 20:48:35 +00:00
$("#addaliasAddress").prop('disabled', true);
$("#addaliasAddress").val(address);
2015-08-14 23:05:08 +00:00
$("#addaliasForwardsTo").val(forwardsTo);
$('#addaliasForwardsToAdvanced').prop('checked', senders != "");
$('#addaliasForwardsToNotAdvanced').prop('checked', senders == "");
2015-07-04 15:31:11 +00:00
$("#addaliasSenders").val(senders);
2015-06-27 17:23:15 +00:00
$('#add-alias-button').text('Update');
2014-08-17 22:43:57 +00:00
$('body').animate({ scrollTop: 0 })
2015-06-27 17:23:15 +00:00
is_alias_add_update = true;
2014-08-17 22:43:57 +00:00
}
function aliases_remove(elem) {
2015-07-04 20:48:35 +00:00
var row_address = $(elem).parents('tr').attr('data-address');
2014-08-17 22:43:57 +00:00
show_modal_confirm(
"Remove Alias",
2015-07-04 20:40:19 +00:00
"Remove " + row_address + "?",
2014-08-17 22:43:57 +00:00
"Remove",
function() {
api(
"/mail/aliases/remove",
"POST",
{
2015-07-04 15:31:11 +00:00
address: row_address
2014-08-17 22:43:57 +00:00
},
function(r) {
// Responses are multiple lines of pre-formatted text.
2020-07-29 14:01:20 +00:00
show_modal_error("Remove Alias", $("< pre / > ").text(r));
2014-08-17 22:43:57 +00:00
show_aliases();
});
});
}
2014-10-11 19:52:00 +00:00
function scroll_top() {
$('html, body').animate({
scrollTop: $("#panel_aliases").offset().top
}, 1000);
}
2014-10-11 17:56:36 +00:00
< / script >