|
| 1 | +--- |
| 2 | +title: "Custom Domains: Receiving Email with Your Own Domain" |
| 3 | +--- |
| 4 | + |
| 5 | +# Custom Domains: Receiving Email with Your Own Domain |
| 6 | + |
| 7 | +> The old version of this documentation is available [here](/receiving_email/custom_domains/). |
| 8 | +
|
| 9 | +The Custom Domain feature allows you to use CloudMailin to receive all email for |
| 10 | +your domain. With Custom Domains you can create a DNS entry in your own domain |
| 11 | +name to allow CloudMailin to accept all email on that domain and forward it onto |
| 12 | +your website just like your regular CloudMailin address. |
| 13 | + |
| 14 | +Each of your CloudMailin addresses can have its own custom domain allowing you |
| 15 | +to use the feature for any number of websites and domains. You can also apply |
| 16 | +multiple custom domains to a single address if required. |
| 17 | + |
| 18 | +## Overview |
| 19 | + |
| 20 | +Let's see an overview of the next steps: |
| 21 | + |
| 22 | +* [Warning: only one email server can be used](#warning-only-one-email-server-can-be-used) |
| 23 | +* [Wildcards and Catch All addresses](#wildcards-and-catch-all-addresses) |
| 24 | +* [Selecting the Region](#selecting-the-region) |
| 25 | +* [Adding the MX records for your domain](#adding-the-mx-records-for-your-domain) |
| 26 | +* [Setting up your CloudMailin address](#setting-up-your-cloudmailin-address) |
| 27 | + |
| 28 | +> We have a beta feature to allow sending different custom domains to a different |
| 29 | +> HTTP endpoint. If you are interested in this feature, please let us know. |
| 30 | +
|
| 31 | +### If you are in a hurry |
| 32 | + |
| 33 | +* [Skip to the MX records section](#adding-the-mx-records-for-your-domain) if |
| 34 | +you don't want to read the full details. |
| 35 | +* [Setting up your CloudMailin address](#setting-up-your-cloudmailin-address) to |
| 36 | + setup your CloudMailin address to use the custom domain. |
| 37 | + |
| 38 | +Custom domains require a paid plan at present. |
| 39 | + |
| 40 | +### Warning: only one email server can be used |
| 41 | + |
| 42 | +Before we can add the MX records it's important to check that the domain is not |
| 43 | +already expecting email. You can do this by checking the MX records for your |
| 44 | +domain. As an example we can check using the host command on mac / linux: |
| 45 | + |
| 46 | +```bash |
| 47 | +host -t mx example.com |
| 48 | +``` |
| 49 | + |
| 50 | +Due to the way that DNS systems work we cannot have multiple servers receiving |
| 51 | +for the same domain. Although adding the records will work we'll randomly see |
| 52 | +different servers receiving the email. If you already have MX records for your |
| 53 | +domain you either need to remove them to add CloudMailin as the only email |
| 54 | +server or you may need to use a subdomain for CloudMailin. |
| 55 | + |
| 56 | +## Wildcards and Catch All addresses |
| 57 | + |
| 58 | +CloudMailin supports wildcards and catch all addresses. |
| 59 | + |
| 60 | +### Catch all email addresses and regular expressions |
| 61 | + |
| 62 | +By default all custom domains are catch all addresses. This means that any email |
| 63 | +addresses to @example.com will be received by CloudMailin. For example, |
| 64 | +`[email protected]` and `[email protected]` will both be received by CloudMailin. |
| 65 | + |
| 66 | +We highly recommend using a pattern for all of your email addresses. For example |
| 67 | + |
| 68 | +use regular expressions to block email addresses that you don't want to receive. |
| 69 | + |
| 70 | +For example you could set the regular expression in the example above to: |
| 71 | + |
| 72 | +```regular-expression |
| 73 | +\w+-\d+@example\.com |
| 74 | +``` |
| 75 | + |
| 76 | +> You can test using [Rubular](https://rubular.com/r/d2rSX5bdxWT1L1) |
| 77 | +
|
| 78 | +This would match any email address that starts with one or more word characters |
| 79 | +and then a dash and then one or more digits. |
| 80 | + |
| 81 | +Taking this approach allows you to block most SPAM attempts that will just try |
| 82 | +random email addresses on your domain. |
| 83 | + |
| 84 | +Remember you should also use the |
| 85 | +[HTTP status code](/receiving_email/http_status_codes/) to reject email that |
| 86 | +you don't want to receive too. |
| 87 | + |
| 88 | +### Wildcard custom domains |
| 89 | + |
| 90 | +CloudMailin also supports a single level of wildcard custom domains. For example |
| 91 | +if you have a custom domain of `*.example.com` then any email to |
| 92 | + |
| 93 | +CloudMailin. |
| 94 | + |
| 95 | +In order to set this up you will need to create wilcard DNS entry with your DNS |
| 96 | +provider (and they must support wildcards). Following this when you |
| 97 | +[setup your domain in CloudMailin](#setting-up-your-cloudmailin-address) you |
| 98 | +will need to add *.example.com instead of example.com as the domain. |
| 99 | + |
| 100 | +## Selecting the Region |
| 101 | + |
| 102 | +In order to add a custom domain we'll need to add MX records to your domain. |
| 103 | + |
| 104 | +> We used to allow adding CNAMEs too but this can cause issues with email being |
| 105 | +> sent to cloudmailin.net rather than with your domain. You can still add a |
| 106 | +> CNAME record as detailed [here](/receiving_email/custom_domains/#cname-records) |
| 107 | +> but we recommend using MX records instead. |
| 108 | +
|
| 109 | +CloudMailin has 3 clusters at present: |
| 110 | + |
| 111 | +| Cluster | AWS Region | MX Record | |
| 112 | +|---------|-----------------|-------------------------| |
| 113 | +| US | us-east-1 | client1.cloudmailin.net | |
| 114 | +| EU | eu-west-1 | client2.cloudmailin.net | |
| 115 | +| AP | ap-southeast-2 | client3.cloudmailin.net | |
| 116 | + |
| 117 | +By default the cloudmailin.net domain will use all three regions but will tailor |
| 118 | +the MX priority to the region of the DNS server making the request. |
| 119 | + |
| 120 | +For example a DNS server in the US will see: |
| 121 | + |
| 122 | +```bash |
| 123 | +10 client1.cloudmailin.net |
| 124 | +20 client2.cloudmailin.net |
| 125 | +30 client3.cloudmailin.net |
| 126 | +``` |
| 127 | + |
| 128 | +and a DNS server in Europe will see: |
| 129 | + |
| 130 | +```bash |
| 131 | +10 client2.cloudmailin.net |
| 132 | +20 client1.cloudmailin.net |
| 133 | +30 client3.cloudmailin.net |
| 134 | +``` |
| 135 | + |
| 136 | +Each of these examples use a different priority for the client1 / client2 email |
| 137 | +clusters to prioritise the server in the region of the user. |
| 138 | + |
| 139 | +(the records will be slightly different because we don't use the client prefix |
| 140 | +for cloudmailin.net) |
| 141 | + |
| 142 | +## Adding the MX records for your domain |
| 143 | + |
| 144 | +When you come to set the DNS record for your own domain you'll need to either |
| 145 | +use geolocation or make a decision around which cluster to use. |
| 146 | + |
| 147 | +Here we'll assume you want to setup the MX records at equal rate: |
| 148 | + |
| 149 | +```bash |
| 150 | +10 client1.cloudmailin.net |
| 151 | +10 client2.cloudmailin.net |
| 152 | +10 client3.cloudmailin.net |
| 153 | +``` |
| 154 | + |
| 155 | +If your DNS provider requires a TTL then you can set this to what make sense for |
| 156 | +your setup but if you're going to play consider using a low TTL like 5 minutes. |
| 157 | + |
| 158 | +Once you've added the MX records you'll need to wait for them to propogate |
| 159 | +and then setup your CloudMailin address to use the custom domain. |
| 160 | + |
| 161 | +## Setting up your CloudMailin address |
| 162 | + |
| 163 | +Once you've added the MX records you'll need to wait for them to propogate |
| 164 | +and then setup your CloudMailin address to use the custom domain. |
| 165 | + |
| 166 | +Once your MX records have propograted head to CloudMailin and open your address |
| 167 | +you should see an option to 'Edit Custom Domains' |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | +Once you click this you'll see the following screen: |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | +Clicking this will allow you to add your custom domain. CloudMailin will check |
| 176 | +that it can see the MX records and that the domain is valid. If everything is |
| 177 | +correct then you'll have successfully added your custom domain. |
| 178 | + |
| 179 | +> If you see an error message containing `regexp` then this is because the email |
| 180 | +> did not meet the regular expression you set. |
| 181 | +
|
| 182 | +You should be all set to send email to your domain and have CloudMailin forward |
| 183 | +it onto your website via HTTP POST webhook. |
| 184 | + |
| 185 | +As always if you have any questions or issues please |
| 186 | +[contact us](https://www.cloudmailin.com/contact_us) and we'll be happy to help. |
0 commit comments