Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP config error: mail loops back to me #379

Open
SethRobertson opened this issue Dec 28, 2024 · 0 comments
Open

SMTP config error: mail loops back to me #379

SethRobertson opened this issue Dec 28, 2024 · 0 comments

Comments

@SethRobertson
Copy link

When an SMTP client connects to davmail and issues a EHLO, davmail spews back a bunch of 250s. The problem is, the FIRST 250 contains the reflected hostname that the client sent on the EHLO. This causes some SMTP implementions (e.g. sendmail) to believe that by some black magic it is talking to itself so the email is rejected by the client with the error "config error: mail loops back to me (MX problem?)".

With EHLO/250, the client provides its name in the EHLO message, and the server provides its name in the 250 response. While what you are doing is technically correct (well, assuming a local client connecting to itself, it is clearly wrong for off-server clients), at least in terms of client compatibility, putting literally anything other than the name you just got would be better. If you want to be conceptually RFC compliant, let the user specify the hostname (instead of the hardcoded "davmail" like I did below) so they can specify a suitable domain name.

I don't have a clean repo to submit a pull request with, so here is a patch:

diff --git a/src/java/davmail/smtp/SmtpConnection.java b/src/java/davmail/smtp/SmtpConnection.java
index baa011ef..66614ee9 100644
--- a/src/java/davmail/smtp/SmtpConnection.java
+++ b/src/java/davmail/smtp/SmtpConnection.java
@@ -90,7 +90,7 @@ public class SmtpConnection extends AbstractConnection {
                     } else if ("NOOP".equalsIgnoreCase(command)) {
                         sendClient("250 OK");
                     } else if ("EHLO".equalsIgnoreCase(command)) {
-                        sendClient("250-" + tokens.nextToken());
+                        sendClient("250-davmail");
                         // inform server that AUTH is supported
                         // actually it is mandatory (only way to get credentials)
                         sendClient("250-AUTH LOGIN PLAIN");

Relevant quotes from RFC-5321:

client normally sends the EHLO command to
the server, indicating the client's identity

In the EHLO command, the host sending the command identifies itself;
the command may be interpreted as saying "Hello, I am " (and,
in the case of EHLO, "and I support service extension requests").

The argument clause contains the fully-qualified domain name
of the SMTP client, if one is available. In situations in which the
SMTP client system does not have a meaningful domain name (e.g., when
its address is dynamically allocated and no reverse mapping record is
available), the client SHOULD send an address literal (see
Section 4.1.3).

ehlo           = "EHLO" SP ( Domain / address-literal ) CRLF
ehlo-ok-rsp    = ( "250" SP Domain [ SP ehlo-greet ] CRLF )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant