1

I'm an application developer and have little knowledge on sysadmin / server configuration tasks.

I have an nginx server communicating to a Flask web application through uWSGI on a VPS. I'm trying to connect to Google SMTP to send mail to my registered users. The Python code all works on my localhost, but I have no idea how to configure nginx to communicate with Google SMTP.

After some research, I have come across the nginx_mail_core module, and some 'mail' blocks in the nginx config - but most of it is rather foreign. If it is indeed a mail block I need to configure, an example would be much appreciated.

Here's my current nginx configuration file:

worker_processes 1;

events {
    worker_connections 1024;
}

http {

    sendfile on;

    gzip              on;
    gzip_http_version 1.0;
    gzip_proxied      any;
    gzip_min_length   500;
    gzip_disable      "MSIE [1-6]\.";
    gzip_types        text/plain text/xml text/css
                      text/comma-separated-values
                      text/javascript
                      application/x-javascript
                      application/atom+xml;

    upstream uwsgicluster {
        server 127.0.0.1:8080;
    }

    # Configuration for Nginx
    server {

        # Running port
        listen 80;

        # Settings to by-pass for static files
        location ^~ /app/static/  {
            root /home/dane/MyApplication/app/static;

        }

        # Proxying connections to application servers
        location / {
            include            uwsgi_params;
            uwsgi_pass         uwsgicluster;

            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
        }
    }
}

Thanks in advance!

weasel
  • 11
  • 1
  • 3
  • Why do you want that? Probably you just need to connect to google smtp for your app – Alexey Ten May 29 '14 at 10:08
  • Hi Alexey, on my local machine I can indeed connect to Google SMTP from my app. When I'm running the application behind nginx, an internal server error occurs. As nginx is being used as a reverse-proxy, I'm assuming it needs to authenticate/know about SMTP requests. – weasel May 29 '14 at 10:23
  • You should investigate the reason of error. Probably some firewall issues. – Alexey Ten May 29 '14 at 10:27
  • Nginx smtp module is for use with your own smtp server and I guess you do not own google ones. – Alexey Ten May 29 '14 at 10:29
  • Thanks for the advice, I will certainly investigate the firewall (CentOS). – weasel May 29 '14 at 10:32
  • These have nothing to do with each other. If you are having trouble sending mail, or getting an internal server error from nginx, then you need to investigate those. – Michael Hampton May 29 '14 at 15:12
  • Yep, Issue found. It was the iptables rules, nothing to do with nginx. – weasel May 29 '14 at 15:35

0 Answers0