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

helo_hostname is not fully realized #3032

Open
dallaslu opened this issue Jul 4, 2024 · 5 comments
Open

helo_hostname is not fully realized #3032

dallaslu opened this issue Jul 4, 2024 · 5 comments
Labels

Comments

@dallaslu
Copy link

dallaslu commented Jul 4, 2024

Describe the bug

Config.dns.helo_hostname, commented with 'The hostname to use in HELO/EHLO when connecting to external SMTP servers'.

But in app/lib/smtp_server/client.rb:

new_io.print("220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{client.trace_id}")

And a few other places.

@dallaslu dallaslu changed the title helo_hostname is helo_hostname is not fully realized Jul 4, 2024
@willpower232
Copy link
Collaborator

The endpoint seems to evaluate a few options before deciding which to be but that isn't used in numerous other places so I agree it is a little confusing.

def default_helo_hostname
Postal::Config.dns.helo_hostname ||
Postal::Config.postal.smtp_hostname ||
"localhost"
end

@schueffi
Copy link

schueffi commented Jul 5, 2024

As I understand it,
helo_hostname is the name it uses for outgoing connections (i.e. acting as a client when sending emails), and defaults to smtp_hostname if not explicitly set. This helo_hostname also needs to be available with a proper PTR record pointing back to your server in order to avoid being considered as spam.

smtp_hosname is used both as a default for the helo_hostname, and, more important, as the name for incoming connections (i.e. when receiving emails). This name is the one you would use in your TLS certificate if you enable TLS/StartTLS on the server side.

As I understand the code, this is implemented correctly in the current main branch already.

@dallaslu
Copy link
Author

dallaslu commented Jul 6, 2024

As I understand the code, this is implemented correctly in the current main branch already.

I agree with what you said. Also, the sending process is independent and does not need to be aligned with the server used to receive the message. Within Postal, if we use the default settings, i.e. only one domain name, there is no problem.

The problem is that when we specify helo_hostname in the config file, the code uses smtp_hostname in a lot of places where helo_hostname should be used.

new_io.print("220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{client.trace_id}")

Should be something like:

new_io.print("220 #{Postal::Config.postal.helo_hostname} ESMTP Postal/#{client.trace_id}")

https://mxtoolbox.com/problem/smtp/smtp-banner-check:

It is best practice to put the name of your server in your SMTP banner so that anybody who connects via your IP Address has a clue as to who they are talking to. You will get this warning if the name you present yourself as is not in the same domain as the hostname we get when we perform a PTR lookup on your IP Address.

@schueffi
Copy link

schueffi commented Jul 8, 2024

The code in "app/lib/smtp_client/..." is used for outbound connections, and properly uses the helo_hostname (if set), and falls back to smtp_hostname (otherwise).

The code in "app/lib//smtp_server/..." is used for inbound connections. This code still uses smtp_hostname instead of the helo_hostname, in order to enable to have two different helo_hostnames for outgoing and inbound connections.

If the server code would be refactored to also use the helo_hostname (so, using helo_hostname always in all places where currently smtp_hostname is used), there seems to be no need to set up two different variables anymore (as the smtp_hostname will never be used, then?) At least, I did not really found a remaining place where the "smtp_hostname" would be used regardless of the helo_hostname setting.

Maybe a better name for the current helo_hostname could be "helo_hostname_for_outgoing_connections_(if_set_and_if_should_be_different_than_the_smtp/helo_hostname_for_inbound_connections)?

Don't know whether this makes sense, and I don't want to argue or judge what is right here. Just giving my thoughts on this topic to help finding the right-thing-to-do.

@dallaslu
Copy link
Author

dallaslu commented Jul 8, 2024

helo_hostname is more important when posting emails outbound. This is because external servers may rely on this to check certificates, PTRs.

I can't think of a situation where you need to deliberately specify different helo_hostname for incoming and outgoing. They can be the same or different.

The helo_hostname config is optional, and its default value is ${smtp_hostname}.

My concern now is that helo_hostname isn't working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants