Relay SMTP port 2525


NethServer Version: 7
Module: mail

I need to configure a domain within the server to serve both internal and external users.

I want to set up a relay for that domain but I need to send to port 2525 instead of 25.

How can I change it?

necesito configurar un dominio dentro del sevidor para atender tanto a usuarios internos como externos.

quiero configurar un relay para ese dominio pero necesito enviar al puerto 2525 en lugar del 25.

de que forma puedo modificarlo?

a temporary solution.

I have edited the /etc/postfix/transport file.

I have modified []: 25 —> []: 2525

Saved and executed
Postmap /etc/postfix /transport
Service postfix restart

Works while the enail settings are not modified since it is rewritten again with port 25.

It would be nice to be able to indicate by relay server and port

I don’t think that you make it via Dashboard interface.

So you can try this:

remove relay domain with “2525” port from GUI interface then, via console:

mkdir -p /etc/e-smith/templates-custom/etc/postfix/transport
cd /etc/e-smith/templates-custom/etc/postfix/transport

Create a file:

vi 11relay

In this file put your relay domain:

# 11relay -- my relay transport     relay:[]:2525


expand-template /etc/postfix/transport


postmap /etc/postfix/transport
service postfix restart

(or you can try with the next comand instead of the two above)

signal-event nethserver-mail-server-update

Thanks @saitobenkei !!

I have a similar problem:
How can I permanently replace port 25 in postfix with port 8025?

Just read @saitobenkei 's post :slight_smile: The idea is to put whatever you want to add or customise into a template. The listening port is not set in but in /etc/postfix/transport.

Sorry, you’re wrong. Port 25 is in as in template 40smtpd_public.

Oh sorry, I mixed up my notes (/etc/postfix/transport is to get postfix relaying mails to another server:port)

Could you finally solve it with a custom template?

No, I do not know how to. I manually changed the 40smtpd_public template and replaced smtp with 8025, but the template is overwritten by the next update and so is the postfix file.

Nethserver uses templates to write the config files. That’s the reason your changes are overwritten on reboot or config change.

Do you really want to REPLACE the port? Why not using a relay port like @pagaille recommended and @saitobenkei has explained?

Sorry, I misunderstood the whole thing :grin:

Just add a custom template to /etc/e-smith/templates-custom/etc/postfix/ with following content:

# 41smtpd_custom -- custom public smtp server on port 8025

8025      inet  n       -       n       -       { $connections_limit > 0 ? $connections_limit: '-' }       smtpd
    $OUT = join("\n", map { "  -o " . $_ } @smtpd_public_options);

Now you have port 8025 open additionally to port 25. I don’t recommend a replacement of the port as it implies a replacement of the 40smtpd_custom template which may lead to troubles with updates.

1 Like

The mails go to port 25 of a mailgate vm with mailscanner first. From there the mails are forwarded to port 8025 of an internal mail server. I think it’s strange enough that the service ports cannot be configured in the GUI. A bit more flexibility would be fine here.

I just misunderstood the whole thing, I edited my post…

You may also config mailscanner to send mails to Nethserver on port 25. These “alternative” ports are only necessary when services are running on the same machine.

By the way…do you like mailscanner? I didn’t know this software before. It’s free and has packages for CentOS, would it be interesting on NethServer?

Maybe that would be okay as well. But I prefer the way with the custom template.

A post was merged into an existing topic: Sophos vs Clamav: who’s the best antivirus?

5 posts were split to a new topic: Sophos vs Clamav: who’s the best antivirus?

Thanks @mrmarkuz !!

I didn’t understood that modifying an existing template like I did (40smtpd_public) wasn’t allowed since it probably wouldn’t survive the next update. Now I know how to add my own custom things.

Could you explain what’s the use of that line ?

It adds the @smtpd_public_options defined in /etc/e-smith/templates/etc/postfix/

@smtpd_public_options = (

to the 40smtpd_public

# 40smtpd_public -- public smtp server on port 25

smtp      inet  n       -       n       -       { $connections_limit > 0 ? $connections_limit: '-' }       smtpd
    $OUT = join("\n", map { "  -o " . $_ } @smtpd_public_options);

to make look like this after expanding the template:

# 40smtpd_public -- public smtp server on port 25

smtp      inet  n       -       n       -       -       smtpd
  -o smtpd_helo_required=yes
  -o strict_rfc821_envelopes=yes
  -o smtpd_proxy_filter=
  -o smtpd_proxy_options=speed_adjust

I think it’s a design concept to have all variables defined in 00template_vars which makes coding easier but I am still learning :slight_smile:

Makes sense now, but cryptic at first sight ! Thanks again.