Setting Up Forwarding
The six endpoints carrying what arrives at a domain somewhere else.
Overview
Forwarding is carrying what arrives at a domain somewhere else. It comes in two kinds and both sit behind the same add-on: mail forwarding carries the post, and address forwarding carries the visitor.
The two differ in number: mail forwarding is a list with a rule per local part, while an address forward is one per domain.
Forwarding is not hosting. No mail is stored and no page is served; what arrives is handed on to another address and nothing more.
Reference
Listing the Mail Forwards
Returns the mail forwards defined on the domain.
curl 'https://panel.example.com/api/v1/client/domains/example.com/email-forwards' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch(`https://panel.example.com/api/v1/client/domains/${domain}/email-forwards`, {
headers: { Authorization: `Bearer ${clientKey}` },
});
if (res.status === 422) return offerAddon(await res.json());
const { data } = await res.json();$ch = curl_init('https://panel.example.com/api/v1/client/domains/' . $domain . '/email-forwards');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// A forward is NOT A MAILBOX: the mail arriving passes to another address and is kept nowhere here.
$rows = Kernel::internal('client:Domains/GetEmailForwards',
['owner_id' => $uid, 'domain' => $domain])['data'];Adding a Mail Forward
Adds a rule carrying mail for the domain to another box.
curl -X POST 'https://panel.example.com/api/v1/client/domains/example.com/email-forwards' \
-H "Authorization: Bearer $CLIENT_KEY" \
-H 'Content-Type: application/json' \
-d '{"prefix":"sales","target":"[email protected]"}'const res = await fetch(`https://panel.example.com/api/v1/client/domains/${domain}/email-forwards`, {
method: 'POST',
headers: {
Authorization: `Bearer ${clientKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ prefix, target }),
});
const { data } = await res.json();
renderForwards(data);$ch = curl_init('https://panel.example.com/api/v1/client/domains/' . $domain . '/email-forwards');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $clientKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(compact('prefix', 'target')),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Send THE LOCAL PART alone: writing a full address adds the domain twice and breaks the rule.
Kernel::internal('client:Domains/CreateEmailForward',
['owner_id' => $uid, 'domain' => $domain, 'prefix' => 'sales', 'target' => $box]);Removing a Mail Forward
Removes a mail forwarding rule.
curl -X DELETE 'https://panel.example.com/api/v1/client/domains/example.com/email-forwards' \
-H "Authorization: Bearer $CLIENT_KEY" \
-H 'Content-Type: application/json' \
-d '{"prefix":"sales","target":"[email protected]"}'const res = await fetch(`https://panel.example.com/api/v1/client/domains/${domain}/email-forwards`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${clientKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ prefix: f.prefix, target: f.target, identity: f.identity }),
});
const { data } = await res.json();$ch = curl_init('https://panel.example.com/api/v1/client/domains/' . $domain . '/email-forwards');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $clientKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($selector),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// One local part can reach SEVERAL targets: send the target too, or they can all go.
Kernel::internal('client:Domains/DeleteEmailForward', ['owner_id' => $uid, 'domain' => $domain,
'prefix' => $f['prefix'], 'target' => $f['target'], 'identity' => $f['identity']]);Reading the Address Forward
Returns whether the domain sends visitors on to another address.
curl 'https://panel.example.com/api/v1/client/domains/example.com/forwarding' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch(`https://panel.example.com/api/v1/client/domains/${domain}/forwarding`, {
headers: { Authorization: `Bearer ${clientKey}` },
});
const { data } = await res.json();
if (data.active) showTarget(data.url, data.method);$ch = curl_init('https://panel.example.com/api/v1/client/domains/' . $domain . '/forwarding');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// There is ONE forward per domain: setting a new one writes over the old, and no list exists.
$f = Kernel::internal('client:Domains/GetUrlForwarding',
['owner_id' => $uid, 'domain' => $domain])['data'];Setting Up an Address Forward
Sends a visitor arriving at the domain on to another address.
curl -X PUT 'https://panel.example.com/api/v1/client/domains/example.com/forwarding' \
-H "Authorization: Bearer $CLIENT_KEY" \
-H 'Content-Type: application/json' \
-d '{"url":"https://shop.example.net/welcome","method":301}'const res = await fetch(`https://panel.example.com/api/v1/client/domains/${domain}/forwarding`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${clientKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ url, method: 302 }),
});
const { data } = await res.json();$ch = curl_init('https://panel.example.com/api/v1/client/domains/' . $domain . '/forwarding');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $clientKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['url' => $target, 'method' => 301]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Browsers CACHE a permanent forward: pick the temporary kind while testing and move to permanent after.
Kernel::internal('client:Domains/UpdateUrlForwarding',
['owner_id' => $uid, 'domain' => $domain, 'url' => $target, 'method' => 302]);Removing the Address Forward
Removes the domain's address forward.
curl -X DELETE 'https://panel.example.com/api/v1/client/domains/example.com/forwarding' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch(`https://panel.example.com/api/v1/client/domains/${domain}/forwarding`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${clientKey}` },
});
const { data } = await res.json();$ch = curl_init('https://panel.example.com/api/v1/client/domains/' . $domain . '/forwarding');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Removing the forward leaves the domain pointing NOWHERE: a visitor lands on nothing.
// Think first about what takes its place; a record or a new target is wanted.
Kernel::internal('client:Domains/DeleteUrlForwarding',
['owner_id' => $uid, 'domain' => $domain]);Pitfalls
All six endpoints of mail and address forwarding sit behind the forwarding add-on. Unbought, or with its invoice unpaid, they all refuse and the answer says which case it is. One purchase opens them both.
An address forward has no list: setting one writes over what was there. There is no adding a second target, and a second call replaces the first. Mail forwarding is a list and carries as many rules as you like.
The source field on a mail forward takes the local part alone and the server adds the domain. Writing a full address adds the domain twice and the rule answers no mail. The source field in the answer shows the right joining.
One local part can forward to several targets. Sending it alone on a removal can take every rule bound to that part. Add the target, and the record id where you hold one.
Picking the permanent kind tells browsers and search engines the address moved for good, and they keep that for a long while. A permanent forward to a wrong target sends visitors there for a time even after the fix. Use the temporary kind while testing.
A mail forward passes the post to another box and keeps no copy. Where the target box is full or refuses the mail, the message is lost with no trace here. A customer wanting a real box should take a mail service.
Related Articles
Vielen Dank für Ihre Rückmeldung!
Unser Support-Team ist rund um die Uhr für Sie da, wenn Sie oben nicht fündig werden.