Relay SMTP port 2525

mail
v7

(Jose Manuel Insausti) #1

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?


(Jose Manuel Insausti) #2

a temporary solution.

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

I have modified

midimonio.com [10.100.0.4]: 25 —> [10.100.0.4]: 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


(Saito Benkei) #3

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
midimonio.com     relay:[10.100.0.4]:2525

Then

expand-template /etc/postfix/transport

Then

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

(Matthieu Gaillet) #4

Thanks @saitobenkei !!


(Ralph) #7

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


(Matthieu Gaillet) #8

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 master.cf but in /etc/postfix/transport.


(Ralph) #9

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


(Matthieu Gaillet) #10

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


(Markus Neuberger) #11

Could you finally solve it with a custom template?


(Ralph) #12

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 master.cf file.


(Markus Neuberger) #13

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

http://docs.nethserver.org/projects/nethserver-devel/en/v7/templates.html

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/master.cf/41smtpd_custom 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.


(Ralph) #14

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.


(Markus Neuberger) #15

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


(Markus Neuberger) #16

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?


Sophos vs Clamav: who's the best antivirus?
(Ralph) #17

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


(Alessio Fattorini) #18

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


(Alessio Fattorini) #19

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


Sophos vs Clamav: who's the best antivirus?
Sophos vs Clamav: who's the best antivirus?
(Matthieu Gaillet) #20

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 ?


(Markus Neuberger) #21

It adds the @smtpd_public_options defined in /etc/e-smith/templates/etc/postfix/master.cf/00template_vars

@smtpd_public_options = (
	'smtpd_helo_required=yes',
	'strict_rfc821_envelopes=yes',
        'smtpd_proxy_filter=127.0.0.1:10024',
	'smtpd_proxy_options=speed_adjust',
);

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 master.cf 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=127.0.0.1:10024
  -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:


(Matthieu Gaillet) #22

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