4

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@site.com" to "email@gmail.com" - can I do this using nginx?

K

MattPark
  • 303
  • 5
  • 20
TheBlackBenzKid
  • 212
  • 1
  • 4
  • 12
  • I believe we might have a case of the XY Problem here (http://www.perlmonks.org/index.pl?node_id=5423410 and that the real question is "How do I set up my server to use gmail to process my email". If this is indeed the case, then this is a server configuration question that would probably be better asked on serverfault. BTW, I personally use this and it is not related to nginx or anyother webserver. – Dayo Nov 11 '11 at 19:23
  • Very enlightening. Good luck with your quest. – Dayo Nov 11 '11 at 23:01
  • what's your domain name registrar? – Stefano Nov 14 '11 at 19:53

2 Answers2

4

As stated by Stefano, no.

If you want to forward me@site.com to me@gmail.com, then go to your site.com email provider and setup forwarding for the account.

  • 3
    But I am site.com... which is why I came here to learn how to redirect mails to an external server, because I don't want to bog down my server with webmail cogs when I can just redirect them. – RaisinBranCrunch Jan 08 '17 at 02:50
3

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:

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;

Stefano
  • 763
  • 1
  • 12
  • 23
  • so nginx after all the hype cannot even be used as a mail server. whereas the dread, poor, pathetic APACHE and LAMP solution comes banging on my door again.. I'm left with a empty house.. –  Nov 14 '11 at 23:37
  • 1
    uh i think you are misunderstanding what an email server is vs web server. If you want to forward your mail, just use the settings your domain provider gives you to setup forwarding. – Martin Samson Nov 15 '11 at 05:13
  • what about nginx actually acting as a mail server? I have seen settings in conf files for smtp and other commands.. –  Nov 15 '11 at 08:38
  • @TheBlackBenzKid: why do you want to do something difficult when you can do something easy? I'm updating my answer with a few more details.. – Stefano Nov 15 '11 at 09:55
  • @TheBlackBenzKid also, you should have provided more details including who's your registrar and what's your current DNS configuration to get more detailed help! – Stefano Nov 15 '11 at 10:12
  • I marked both @MartinSamson and yourself (@Stefano) repped. This is the closest thing I will come to it. I already have Gmail forwards via the Google app on this domain. DNS is DynDNS who handle mail ironically and Host is Rackspace (they given basic DNS options in the admin for MX records so does DynDns). I am happy with this answer. I will have to keep looking around nginx to see what can be done. Alternative is since the server instance is on Ubuntu 11 - might as well get a Cpanel.. an opensource one that supports nginx.. –  Nov 15 '11 at 11:02
  • an opensource cpanel that supports nginx I am guessing will build in the mail handlers. –  Nov 15 '11 at 11:02
  • 1
    @TheBlackBenzKid: http://stackoverflow.com/questions/670628/is-there-any-opensource-software-like-cpanel for open source "cpanels".. But really, doing DNS based mail configuration _is_ the best way to use gmail: I can't imagine what nginx could provide more. I guess that your domain name registrar is Rackspace, so you should not even need DynDNS that provide paid-for mail redirection. – Stefano Nov 15 '11 at 13:48
  • @Stefano I just realised. My PHP scripts use sendmail(); but its not working! This is also what I really wanted to do. How do I enabled nginx to allow PHP to use sendmail?? –  Nov 15 '11 at 20:56
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/5043/discussion-between-stefano-and-theblackbenzkid) – Stefano Nov 16 '11 at 09:50