I used to have a CPanel/Plesk server so I didn't setup email via command line etc.

I don't want an email pop3 account or mail server. Just want to forward "[email protected]" to "[email protected]" - can I do this using nginx?

K


Solution 1:

There's a similar question here: https://stackoverflow.com/questions/511198/nginx-as-mail-proxy with a geeky answer but the very easy answer would be: no.

The thing is: while nginx does have a mail module and mail proxy features capable of handling smpt, imap, pop3 I'm having an hard time understanding which configuration does really require this. I'm not even sure it is compiled by default with pop/smpt/imap support, so you might have to rebuild it yourself. My point is not that you can't do it, just that it's overkill because there are easier ways.

This is a sample nginx conf (from here) for dealing with mail:

# To proxy pop3/imap/smtp recommended to set to the number of CPU
  worker_processes 1;

  error_log / var / log / nginx / error.log info;

  mail {
      server_name ORIGINALMAILSERVERNAME;
      auth_http LOCALSERVERAUTH; #NGINX FORWARDS AUTHENTICATION REQUESTS TO THIS URL

      imap_capabilities "IMAP4rev1" "UIDPLUS" "IDLE" "LITERAL +" "QUOTA";

      pop3_auth plain apop cram-md5;
      pop3_capabilities "LAST" "TOP" "USER" "PIPELINING" "UIDL";

      smtp_auth login plain cram-md5;
      smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN;
      xclient off;

      server {
          listen 25;
          protocol smtp;
          # The RFC 2821 timeout should be 300 seconds
          timeout 300s;
      }
      server {
          listen 110;
          protocol pop3;
          proxy on;
          proxy_pass_error_message on;
      }
      server {
          listen 143;
          protocol imap;
          proxy on;
      }
      server {
          listen 587;
          protocol smtp;
          timeout 300s;
      }
  }

In each of the Server { listen } section you can do whatever you want, including proxying to other severs such as gmail.

But I suppose you have bought a domain name: most domain name registrar still propose some interfaces to simply redirect emails - that's definitely the easiest way. Set up a catch-all to go to your gmail address.

Otherwise: edit your domain DNS settings, get a google app account and follow their tutorial; it's free up to 10 accounts: http://www.google.com/apps/intl/en/group/index.html and very easy.

You will need to edit your DNS settings. Depending on where you registered your 'mysite.com' domain name mileage will vary.

Unluckily I can't provide you with specific links, but you should do the following:

  • create a free google apps account: https://www.google.com/a/cpanel/domain/new?hl=en
  • You will get to an adminisitrative interface. I remeber that's a wizard that should help you, otherwise click on "Setup" -> "Setup Apps" -> "Gmail"

from there, you will get very detailed instructions.

There are probably other hosted mail solutions, and I do not work at google, but you want to read mails in a gmail interface so this should be the easiest way. I have myself a free google app account myself and very happy with it;

Solution 2:

As stated by Stefano, no.

If you want to forward [email protected] to [email protected], then go to your site.com email provider and setup forwarding for the account.