通过lua nginx超时错误发送电子邮件

时间:2014-11-12 18:48:01

标签: email nginx lua server

我试图通过lua + nginx发送电子邮件。

Lapis(Lua)代码

local smtp = require("socket.smtp")
app:get("/ee", function(self)

    local from = "<mail0@mydns.name>"
    local rcpt =  {
      "<mail1@gmail.com>"
    }

    local mesgt = {
      headers = {
        to = "PP <mail1@gmail.com>",
        cc = '"V.V." <mail2@gmail.com>',
        subject = "My first message"
      },
      body = "I hope this works. If it does, I can send you another 1000 copies."
    }


    local r, e = smtp.send{
      from = from,
      rcpt = rcpt, 
      source = smtp.message(mesgt),
      server = "127.0.0.1", 
      port = 25
    }

    return  "R:" .. tostring(r) .. "  E: " .. tostring(e)
end)

给出超时错误(经过几秒钟后):"R: nil E: timeout"

Nginx配置是:

http{
      server{
        listen 9000;
        location = /cgi-bin/nginxauth.cgi {
            add_header Auth-Status OK;
            add_header Auth-Server 127.0.0.1;  # backend ip
            add_header Auth-Port   25;        # backend port
            return 200;
        }
    }

}

mail {
    auth_http         localhost:9000/cgi-bin/nginxauth.cgi;

   server {
        server_name     mydns.name;
        listen          25;
        protocol        smtp;
        proxy           on;
        timeout 5s;
        proxy_pass_error_message on;
        #smtp_auth       login plain;
        xclient         on;
        smtp_auth none;
    }
}

我不了解邮件服务器的核心。如何配置?如何使用nginx服务器?我认为由于邮件服务器只是重定向而导致超时错误,但是没有处理电子邮件数据,对吗?或者我该怎么做以解决错误?

0 个答案:

没有答案