DEV Community

Cover image for How to setup a mailbox with custom domains?
Glenn Carremans
Glenn Carremans

Posted on

How to setup a mailbox with custom domains?

I have a couple of domains for all kinds of different projects, some on shared hosting (with a mailbox solution from the provider) and some on a private VPS.

My goal is to move everything to my VPS but the problem I currently have is that I don't know how to setup a mail server solution. Any advice would help me a lot, do you have your own mail server solution or are you using a 3rd party service?

Maybe some requirements that I currently have:

  • Supports multiple domains
  • SMTP so I can send mails from my backend application
  • Can create multiple mailboxes if needed

I understand that there is not 1 perfect solution but any tips are welcome to help me reach my goal.

Discussion (22)

Collapse
georgehanson profile image
George Hanson

I have needed to do the exact same before. I found a great open source tool called Mail in a box. It requires a little bit of setup but it is documented fairly well and I believe they even have a video tutorial. Might be worth checking it out -github.com/mail-in-a-box/mailinabox

Collapse
jeffreyfate profile image
Jeffrey Fate

Thanks for the mailinabox tip. Launched my on AWS and after a little fighting with security groups and DNS, it is receiving email.

I wanted email on my own domain without using a hosting provider and this solves that. Thanks!

Collapse
glennmen profile image
Glenn Carremans Author

Very interesting, I will definitely check this out!
Did you install this on the same server as your other applications or a dedicated VPS for mail only?

Collapse
georgehanson profile image
George Hanson

On a dedicated VPS. Depending on your needs, a small $5 or $10 digitalocean droplet will suffice

Thread Thread
glennmen profile image
Glenn Carremans Author

Thanks again! I will try this and if I get it working and has everything that I was expecting I am going with this option.

Thread Thread
cocoonkid profile image
cocoonkid

You'll love it. I promise.

Collapse
ben profile image
Ben Halpern

There are different ways to do this, but Rails is about to ship features around this use case (I think).

Introducing Action Mailbox for Rails 6

A lot of Rails is designed to abstract away typically over-complicated domains, so this will probably be a decent solution.

Collapse
glennmen profile image
Glenn Carremans Author

Very interesting, will be looking out for the official release and any projects that might flow from this.
As you know I don't have much experience in Ruby, but I still try my best πŸ˜‰so I don't know if this is a solution for me to have a solid mail solution but still interesting to maybe play around with in the future.

Collapse
belinde profile image
Franco Traversaro

Not a real suggestion, but pay attention to SMTP configuration: it's too easy to miss some obscure conf and be labeled as a possible spammer, so your email won't be delivered. I really think that using an external SMTP is WAAAAAY better.

Collapse
glennmen profile image
Glenn Carremans Author

I will use those online mail scanner tools that will give a spam score and suggestions to improve my mail settings. I understand what you are saying and that setting up a mail server costs time.

Collapse
picocreator profile image
Eugene Cheah • Edited

Well if you are DIYing the whole solution on your VPS. You might be able to hack together something using mailgun API which can do the heavy lifting for you.

It supports both SMTP for sending of emails, and an API for receiving of emails.

Quite easy to hack together your own inbox - we did so for a temporary inbox project inboxkitten.com

See : dev.to/uilicious/the-stack-making-...

And could be easily extended out for long term storage.

Alternatively, the full real hard-core way would be to do the self-hosting of mail servers yourself. However this is an uphill battle not in getting it to work, but ensuring that your mail servers are configured will to not get marked as spam, etc. I tried... T_T

Collapse
glennmen profile image
Glenn Carremans Author

Thanks Eugene for sharing your project, indeed an option would be to build something myself but that is not what I am currently looking for. But still I will keep it in mind and maybe in the future this will help me.

I think I am going with this option: github.com/mail-in-a-box/mailinabox
But still open for feedback, don't have time this weekend so am probably not going to work on it just yet.

Collapse
picocreator profile image
Eugene Cheah

Took a look at mailinabox, it looks potentially a good fit for a plug and play (im assuming you already have existing systems needing SMTP/IMAP). =)

Collapse
jmtiong profile image
Jia Ming

Hello! Although it is not relevant, if you only need to receive email, I know that you can use github.com/uilicious/inboxkitten to do it! You can deploy your own version of Inboxkitten in Firebase (the steps are in the github) and use your own domains for your usage.

Collapse
glennmen profile image
Glenn Carremans Author

Thank you for sharing this project, very interesting. But I think that this isn't exactly what I was looking for. I am looking for a full mail server solution (sending and receiving).

Collapse
jougs profile image
Jochen Martin Eppler

I don't know if this is too oldschool, but why don't you setup a postfix/dovecot server? That'd give you virtual mailboxes for as many domains as you like and SMTP and IMAP access. You could even add centralized spam filtering if you'd like.

Collapse
glennmen profile image
Glenn Carremans Author

I actually tried this (I think a year ago) but couldn't find good documentation at the time so got lost in the complexity and gave up.
I was also trying this on my VPS where I have other applications running and wanted to avoid breaking anything else.

Collapse
jt89 profile image
jt89

if you want to do everything on your own (which can be a huge pita) -> this can be a good start: github.com/Kickball/awesome-selfho...

Collapse
glennmen profile image
Glenn Carremans Author

Thanks for this list! Any recommendations?

Collapse
gautamkrishnar profile image
Gautam krishna R

I am using zoho

Collapse
tonymet profile image
Tony Metzidis

SES is a managed service for sending and receiving mail. Sending is trivial, and here are the docs for receiving
docs.aws.amazon.com/ses/latest/Dev...

Collapse
glennmen profile image
Glenn Carremans Author

Thanks for the suggestion, for someone like us this might be useful but on first sight it doesn't seem useful if I would ever setup a mailbox for someone else. But I will still keep it in mind!