With postfix, error sending mail

SYSTEM INFORMATION
OS type and version Ubuntu 22.04
Webmin version 2.105

After installing posfix and mailutils

With
echo “Test 1 from $(hostname -f)”|mail -s “Test 1 $(hostname -f)” my-email@gmail.com

In Webmin / Postfix Mail Server / Mail Queue I get
From: pc-user@mydomain.tld
To: my-email@gmail.com
Status: connect to alt2.gmail-smtp-in.l.google.com[IPV6-Address]:25: Network is unreachable

With
echo “Test 1 from $(hostname -f)”|mail -s “Test 1 $(hostname -f)” my-email@my-otherdomain.tld

In Webmin / Postfix Mail Server / Mail Queue I get
From: pc-user@mydomain.tld
To: my-email@my-otherdomain.tld
Status: connect to mx01.My-ISP[IP-ISP]:25: Connection refused

In General Options / What domain to use in outbound mail = Use domainname

Furthermore
sudo ufw disable

It seems to be a problem with port 25 and if I remember correctly, ISP mail servers now reject it.

How do I set up the 587?

Lets simplify for a second … what happens if you send the email to and from the same local domain ?

Two possible problems.

  1. You have misconfigured IPv6. Are you meaning to use IPv6, and is it correctly configured?
  2. You don’t have port 25. Your ISP/hosting provider may block port 25 to prevent spam. If this is the case, you’ll have to see if they’ll unblock it, otherwise you can’t send mail directly from this server, you’ll need a relay.

and a general comment – note that many ISP/hosting providers block incoming port 25; if that’s so in your case, then your server cannot RECEIVE any mail.

@jimr1
I have no mail users on this domain which I use only for service.
I didn’t expect to have to receive messages.
Furthermore, the only mail server present is this Postfix.
So, if I want to receive mail I should configure it (I installed it yesterday and only configured the Sending section).

@Joe
There is no IPV6 on the network. Maybe IPV6 is configured Ubuntu server 22.04 which I installed a few days ago; I should disable it on the network card.

@Joe
@verne
I already asked my ISP yesterday (Saturday morning) if they blocked port 25.
Obviously the 24/7 help desk service works when someone, kindly, opens the mail on Monday. :wink:

But I would assume that GMail blocks it and I can’t know if other ISPs block it.
In fact when I configure email clients I always use SMTP ports 465 or 587 for any external domain.

From this consideration my request to understand how to configure Postfix to use the 587.

All mail servers need port 25 to communicate, if your ISP blocks it, to mitigate spam being sent from their network, that’s fair enough, but in this case they will open it for you.

  • Port 587: This port is typically used for email submission by mail clients (e.g., Outlook, Thunderbird) to a mail server. It is part of the standards defined in the Simple Mail Transfer Protocol (SMTP) for email transmission. Port 587 usually requires authentication and encryption, providing a secure connection for sending emails. It is commonly used for the submission of outgoing mail.
  • Port 465: This port was previously used for Secure SMTP (SMTPS). It has now been deprecated by the Internet Engineering Task Force (IETF), and its use is not recommended. However, some legacy email systems may still use Port 465 for SMTP with SSL/TLS encryption.

You could do that, but you can’t configure the rest of the world to use port 587. Port 25 is the SMTP port, if you don’t have port 25, you do not have a mail server. There is nothing you or I can do about that.

You’d need a relay (which is a service that accepts mail on the submission port, authenticated, and relays it on to port 25 on the recipient server on your behalf). There are many such services. Some have a free tier of a few hundred emails a month, none are very expensive. We pay about 10 bucks a month for this forum to relay through Mailgun (we have port 25, but in this case I’d rather pay someone else to worry about deliverability).

In my particular case I send an email to my provider and therefore I can ask him to open the 25 for me.
However, theoretically, I could send the error email to anyone else, for example to GMail and Google would never open it for me.

There is another alert service configured on my firewall that forwards error messages to this same mailbox of my domain and for this service I use 587, SSL, username and password.

Can’t I configure Postfix to do the same?

I also don’t understand another thing.
This Postfix was created to send error messages, but I could also create users on the server who send their personal messages and I certainly won’t be able to ask all ISPs to open their port 25 for me.

Reasoning in this way, instead of hypothesizing the user John who uses Thunderbird to send Christmas greetings, I can have the user John who sends an error using Fail2ban.
Both will use Postfix with their own credentials and with port 587.

Or am I still wrong?

My ISP responds to me saying that I cannot send emails from my Postfix server since the MX records are those of the same ISP.

Not wanting to change the MX record, I was thinking of another route, but I can’t imagine how much this could complicate my life.
Postfix should collect the message to be sent and pass it to the ISP’s mail server.
In the near future I could then configure it to receive mail; so, the ISP’s mail server receives it from the Internet and Postfix downloads it from this.
With this configuration I could access mail on Postfix and also on the IPS mail server if desired, either with its Webmail or with Thunderbird.

However, at the moment my current goal is to forward messages that arise from applications on my server.
I would prefer to manage everything through Postfix, but if it all becomes too complicated, then perhaps it is better to disable it now and configure the applications to send messages directly to the ISP server.

That doesn’t make sense. MX records have nothing to do with sending email, they are about what server should receive an email.

What? I’m having a hard time understanding how you think all of this works.

You can create all the users you want, but if you don’t have port 25 outgoing from your server you cannot send mail to the world, and if you don’t have port 25 incoming you cannot receive mail from the world. Port 587 is the submission port for authenticated users to send mail through your server. But, that just puts it in the outgoing queue in Postfix. It is never leaving without port 25. I don’t know how to be more clear about this. If you do not have port 25, you do not have a mail server!

What is Postfix supposed to do with the messages? If you don’t have port 25, Postfix cannot send mail.

Google and GMail absolutely have open port 25! That’s how mail works! Every mail server on the entire internet has open port 25. That’s the SMTP port. When you send mail to a user @gmail.com the sending server connects to port 25 on one of their MX servers, and sends the mail.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.