Setting up a mail (proxy?) server?

Started by
4 comments, last by Cornstalks 10 years, 10 months ago

I'm just getting into managing servers and am enjoying myself tinkering with things. Right now, I have a domain name and a private server hosting my website on said domain. Right now I'd like to set up email so I can have whatever@mydomain.com be my email address. However, I've got too much tied to my current gmail account to abandon it, so now I'm looking for a way to send email as whatever@mydomain.com from gmail and simply forward all email received by whatever@mydomain.com to my gmail account. I have no idea what I'm doing here, so if I'm saying something that doesn't make any sense... well... correct me :)

What I have:

A gmail account

A server (with Ubuntu Server and nginx)

A domain name

A DNS with (MX) records I can edit

What I want:

(Part 1) Very simple, minimal resource system on my server that allows me to receive email at whatever@mydomain.com, and immediately forwards that to my gmail account. (Part 2) I also want to be logged into my gmail account and be able to send email as whatever@mydomain.com. I want all email transmitted and received by my server to be encrypted (I have an SSL certificate, if that's necessary). I don't want to be able to log into my mail server and check my email that way (through a web client). I only want to interact with it through my gmail account. Basically, I don't even want to know (from a usability standpoint) that my server exists. Also, I don't want to do any spam filtering, as I expect gmail to take care of that.

What I think I need to do (but have no idea if I'm headed in the right direction):

For part 1, I think I need to setup some kind of mail proxy server (correct me if I'm wrong!). From what little googling I've done, I've heard nice things about Postfix, but am still completely unsure of what to do. For part 2, I'm sure I need to set up my proxy to use SMTP, but again, that all depends on what program I've chosen to act as my proxy.

My question:

Do you have any direction you can offer me on this? I'm not even sure if an email proxy is what I want, so if you can at least tell me the words I should be googling or the right name of things I should be using, that would help a lot. Is Postfix able to be a simple, thin mail proxy?

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Advertisement

I can't help sadly but I just want to subscribe to this thread. I am also having mail issues with my VPS.

Setting up mail servers in Linux is nasty business.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

This is why I never touch Linux based servers unless there is a gun pointed at my head. Massively overcomplicated.

On Windows SE, once I have a dedicated IP, I set up a basic hMailServer and that's it.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Okay, here's what I've done. From what little testing I've done, it's working great. If anyone has any insights, I would love to hear them (because I have no clue what I'm doing).

Install postfix:

apt-get install postfix

It will go through a setup process. I selected "Internet website" (or whatever it was called... not "satellite" or "smart host" etc.). Give it the server name you want (for example, do domain.com if you want to receive email at user@domain.com). I then edited aliases:

vim /etc/aliases

And set up aliases for users:

user1: user1email@gmail.com

user2: user2email@gmail.com

Saved and closed, and then refresh with newaliases

newaliases

And then reloaded postfix:

postfix reload

Now, when I send email to user1@domain.com it immediately gets forwarded to user1email@gmail.com (similarly for user2). Note that user1 and user2 are not actual usernames on my server. They're just aliases that exists in the postfix mailing system. Also, they do not receive email on the system (that is, email sent to user1@domain.com does not get saved on the server; it immediately gets forwarded to user1email@gmail.com).

I'm going to double check things and make sure everything is being encrypted like it should be...

Okay, so I just did the following:

vim /etc/postfix/main.cf

Add the following:

smtp_tls_security_level=encrypt
smtp_sasl_security_options=noplaintext, noanonymous
smtp_sasl_tls_security_options=noplaintext, noanonymous
Then restart (probably could've just done a reload):
/etc/init.d/postfix restart
This forces TLS encryption. You can also set smtp_tls_mandatory_ciphers (defaults to medium) and smtp_tls_mandatory_protocols (defaults to !SSLv2 because SSL v2 has some known weaknesses), but I was happy with these defaults. If you want to know more about options for main.cf, just do man 5 postconf. Make sure to reload postfix after editing main.cf.
Additionally, sending email to an invalid email address (for example: invalidemail@domain.com) results in a permanently failed "Recipient address rejected: User unknown in local recipient table" response, which is exactly what I want. I could probably make it silently fail but I don't care to do that.
I'll continue checking this setup and seeing if I can find any potential issues with it. If I find any issues or make any changes, I'll post back here.
Oh yeah, I forgot about the MX records. If anyone is curious, I just added a single MX record in my DNS with priority 10 and value "domain.com." (yes, there is a period after com).
Edit: I forgot about sending email using my custom domain. This was easy. I just went to my Gmail account, then settings, then accounts, and then where it says "Send mail as:" you can just add the new email address with the custom domain. I set it up as an alias and used Google's SMTP servers to send mail. It sent a verification email, which conveniently my server just forwarded to my gmail's inbox. I'm now send and receiving email with my custom domain, while still using gmail with my Google account.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

Why are you doing this exactly? You've introduced a single point of failure in your email delivery system. A system which is designed to be stable and redundant That's why you can have multiple MX records. You'd be much better served just using Google Apps if you want Gmail for your custom domain.

Why are you doing this exactly? You've introduced a single point of failure in your email delivery system. A system which is designed to be stable and redundant That's why you can have multiple MX records. You'd be much better served just using Google Apps if you want Gmail for your custom domain.

Yeah, I know. I've been thinking about the single point of failure. I don't want to pay for Google Apps though, nor do I want yet another Google account (I've got like 5 or so already, the last thing I want is another one; I wish they could all be merged into the same account, but they can't).

One major reason for doing this is to learn. I've never done much server work, so I'm learning a ton by doing this. Seeing as this email will not be used for anything critical, I'm okay if it goes down with my server.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This topic is closed to new replies.

Advertisement