exim4 和我的代码发生 554 SMTP 同步错误

发布于 2024-08-22 07:08:06 字数 1409 浏览 16 评论 0原文

我已经遇到了来自 exim4 的拒绝错误:

2010-02-15 01:46:05 SMTP 协议同步错误(输入发送而不等待问候语):拒绝来自 H=ender [192.168.20.49] input="HELO 192.168 的连接.20.49\r\n"

我已经修改了我的 exim4 配置以不强制同步,如下所示:

 smtp_enforce_sync='false'
 acl_smtp_connect = nosync nosync:
         control = no_enforce_sync
         accept

但这似乎并不重要。对我来说不太有意义的是为什么我首先购买 554。我发送一个 HELO,等待响应,不知何故,在这中间,我设法生成“554 错误”

我在下面的代码中做错了什么,这使得 99% 的时间都失败(是的,它已经工作了两次)。是的,套接字正在阻塞,我挂在接收状态大约 5 秒等待拒绝。在它工作的两次中,它根本没有暂停。

我尝试过发送 EHLO 而不是 HELO,但运气不佳。我什至对通过 telnet 会话进行连接并说“HELO”感到悲伤。但是,我可以使用 python smtp(从另一台机器)在同一台服务器上发送电子邮件!

        hSocket = _connectServerSocket(server, port);    
    if (hSocket != INVALID_SOCKET) {        
        BYTE        sReceiveBuffer[4096];
        int            iLength = 0;
        int            iEnd = 0;
        char        buf[4096];

        strcpy(buf, "HELO ");
        strcat(buf, "192.168.20.49");
        strcat(buf, "\r\n");
        printf("%s", buf);
        if (send(hSocket, (LPSTR)buf, strlen(buf), NO_FLAGS) == SOCKET_ERROR) {
            printf("Socket send error: %d\r\n", WSAGetLastError());    
            return (false);
        }
        iLength = recv(hSocket, 
                       (LPSTR)sReceiveBuffer+iEnd,sizeof(sReceiveBuffer)-iEnd, 
                        NO_FLAGS);
        iEnd += iLength;
        sReceiveBuffer[iEnd] = '\0';

I have run headfirst into this reject error from exim4:

2010-02-15 01:46:05 SMTP protocol synchronization error (input sent without waiting for greeting): rejected connection from H=ender [192.168.20.49] input="HELO 192.168.20.49\r\n"

I have modified my exim4 config to not enforce sync, like so:

 smtp_enforce_sync='false'
 acl_smtp_connect = nosync nosync:
         control = no_enforce_sync
         accept

But that doesn't seem to matter. What makes less sense to me is why I'm getting the 554 in the first place. I send a HELO, I wait for a response, and somehow in the midst of that, I manage to generate the "554 Error"

What am I doing wrong in the code below, that makes this fail 99% of the time (yes, it has worked twice). Yes, the socket is blocking, I hang in recv for ~5 seconds waiting for the rejection. On the 2 times when it has worked, it didn't pause at all.

I've tried sending EHLO instead of HELO, no better luck. I've even had grief getting a telnet session to connect and say HELO. However, i can use python smtp (from another machine) to send emails just fine against this same server!

        hSocket = _connectServerSocket(server, port);    
    if (hSocket != INVALID_SOCKET) {        
        BYTE        sReceiveBuffer[4096];
        int            iLength = 0;
        int            iEnd = 0;
        char        buf[4096];

        strcpy(buf, "HELO ");
        strcat(buf, "192.168.20.49");
        strcat(buf, "\r\n");
        printf("%s", buf);
        if (send(hSocket, (LPSTR)buf, strlen(buf), NO_FLAGS) == SOCKET_ERROR) {
            printf("Socket send error: %d\r\n", WSAGetLastError());    
            return (false);
        }
        iLength = recv(hSocket, 
                       (LPSTR)sReceiveBuffer+iEnd,sizeof(sReceiveBuffer)-iEnd, 
                        NO_FLAGS);
        iEnd += iLength;
        sReceiveBuffer[iEnd] = '\0';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

全部不再 2024-08-29 07:08:06

在发送 HELO 消息之前,您的代码应等待来自 smtp 服务器的 220 行。请参阅 RFC 2821 的第 3.1 节。这可能就是 Python 库的作用。

应该有几个可用的免费库可以帮助您解决此问题,例如 libsmtp。考虑花时间学习其中之一,而不是修补您自己的解决方案(除非您的项目是编写自己的邮件解决方案)。

Your code should wait for a 220 line from the smtp server before sending the HELO message. See section 3.1 of RFC 2821. That is probably what the Python library does.

There should be several free libraries available that can help you with this, for example libsmtp. Consider spending time on learning one of these instead of patching your own solution (unless your project is to write your own mail solution).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文