merubuntu
By:
merubuntu

Setup a "mail.xxx.com" in Digital Ocean (when xxx.com's hosting server is located in Amazon S3)

January 1, 2015 40.5k views

Hi guys.
I'll try to explain as detailed as possible.

  1. I own a Namecheap domain. And it's web server is located in Amazon S3 and all directions xxx.com and www.xxx.com are routed with Amazon Route53.
  2. The point is: my customer wants a corporative mail ( @xxx.com) which server is now placed in DigitalOcean (ubuntu 14.xx).

The point is that my last step is to register the mail.xxx.com domain and point that domain to my IP DigitalOceans's mail server.

But when I apply that action automatically it creates three "NS" records (which the digital oceans by-default-nameservers) and one "A" record (pointing to the IP). At this time I also created in Amazon Route53 a new "record set" of type MMX with the "mail.xxx.com" route and pointing to the three DigitalOcean "NS" directions.

Finally when I make a ping or trace mail.xxx.com it has no results in return.

I'm a little bit frustrated.
In case you can help us, I would appreciate it.

Thanks in advance.

R.R.

8 Answers

Point the MX record at your droplet's IP address, not at the DigitalOcean nameservers.

This is because it is the nameservers which you create the records on which also do the pointing to the target for each record. In your case that's Amazon Route53, so you do not need to use DigitalOcean's. In fact, you cannot use both at once.

An alternative method would be to change the DNS settings in your Amazon Route53 to point at DigitalOcean's nameservers and do not set up any records at all on Amazon Route53. Then you can create all of the records on DigitalOcean's nameservers and point the MX to your droplet and the A (or all the As) to your Amazon S3 IP address(es).

Hope that helps. Ask away if that doesn't make it clear.

  • @freshscaped thansk for your answer.

    So, in case I apply your first solution, do I not have to create any domain in DigitalOcean?

  • Correct, raul. Just point the MX record at the droplet using Amazon's nameservers and fire up your email server on your droplet.

Apologies raul, the answer I gave was incomplete. To get a mail server running on a droplet, you must first create an A record on the Amazon system, which effectively sets up a subdomain.

You can call it anything-you-like.xxx.com, so your original idea of mail.xxx.com is good, as would be post.xxx.com and many others. This new A record must have the subdomain name and point to your droplet's IP address.

Then you make the MX record and follow on from there.

@freshscaped, I was thinking about it.
At the end I set up one A record pointing to the IP address of my droplet.
And later, one MX record pointing to the IP address, and also the priority of that record (10). Because it's just one IP, I put one line with that IP address.

Now I'm testing connections and configurations of the mail server. Still with problems about how to connect Outlook and Thunderbird with them (I followed the guide for this mail server

That sounds OK. Just ensure the web sites are not affected.

That is a very advanced mail server. Follow the comments below it to see what problems others have encountered with it. Keep pressing the button at the bottom for "more comments" - there are lots of them.

Are you getting any response in Outlook or Thunderbird when you try to connect? Have you taken a look at the log files in /var/log/ on your droplet, especially syslog, mail.log and mail.err? Do any of those offer clues as to what is happening?

You could follow this link for an easier set up. If that works OK then go back to the more complex one. Once set up that is very stable and far more secure.

by Lukas Erlacher
This tutorial will tell you how to setup a basic mail server and attempts to teach you a bit about the Postfix MTA (Mail Transfer Agent) in the process.

@freshscaped thanks again.

Let me say that for now I send mails (for Yahoo, Google, Outlook). Listening on port 587 for SMTP I send mails from @xxxx.com account to N acounts. :)

But for IMAP case, I do not have a clear reason why I cannot receive any mails from other accounts (Outlook, Gmail, Yahoo, etc.) to my @xxxx.com account.

I checked mail.err (empty) and mail.log report me this:

Jan  2 22:15:43 mail dovecot: imap(miguel@yrma.biz): Disconnected: Logged out in=4128 out=9425
Jan  2 22:15:43 mail dovecot: imap(miguel@yrma.biz): Disconnected: Logged out in=1862 out=5645
Jan  2 22:15:43 mail dovecot: imap(miguel@yrma.biz): Disconnected: Logged out in=1043 out=3632
Jan  2 22:16:00 mail dovecot: imap-login: Login: user=<miguel@yrma.biz>, method=PLAIN, rip=181.67.17.135, lip=104.236.108.28, mpid=1553, TLS, session=<70Vr4$
Jan  2 22:16:33 mail dovecot: imap-login: Login: user=<miguel@yrma.biz>, method=PLAIN, rip=181.67.17.135, lip=104.236.108.28, mpid=1559, TLS, session=<q3Vf4$
Jan  2 22:16:35 mail dovecot: imap-login: Login: user=<miguel@yrma.biz>, method=PLAIN, rip=181.67.17.135, lip=104.236.108.28, mpid=1561, TLS, session=<Br1+4$
Jan  2 22:18:30 mail postfix/anvil[1538]: statistics: max connection rate 1/60s for (submission:181.67.17.135) at Jan  2 22:15:08
Jan  2 22:18:30 mail postfix/anvil[1538]: statistics: max connection count 1 for (submission:181.67.17.135) at Jan  2 22:15:08
Jan  2 22:18:30 mail postfix/anvil[1538]: statistics: max cache size 1 at Jan  2 22:15:08

Hope anyone can help me.
Thanks!
R2

Raul you are very close to having a secure, stable, viable mail server. Try to log in with a couple of client accounts then run 'tail -n 50 /var/log/syslog'.
See if there is anything which gives you a strong clue and read back through the comments on the tutorial if anything looks familiar. Otherwise, post the outcome on something like pastebin.com and let us have a look by posting the link here..

Ok @freshscaped now this is my answer.

The problem was that, while I was following this guide -which is very similar to this other one my error was in the virtual_aliases table.

Its use was not meaningful for me until the explanation I read was clear:

"This lets you forward mail from one email address to another. This command will create a table called virtualaliases. It has an id field, a domainid field which will associate each entry with a domain, a source field for the original email address, and a destination field for the target email address"

Ok, so an alias account is not saved in the server, just used to forward all their incoming messages to (i) another @example.com account or (ii) any other mail. Be careful because in case you put an account that is not considered as an alias type, none of their incoming messages will be stored in the server.

Two days of hard thinking... #WhyME!!!
Thanks for your support.

Have another answer? Share your knowledge.