Use other SMTP , if must setup mail postfix, sendmail?

Hello everyone, may I ask if I need to activate any other SMTP services on ROCKLINUX to enable the website to send emails? Do i still need to install something? Because it’s not using the built-in MAIL function, is it okay not to install postfix, sendmail, etc? Is it possible to simply open ports 25 and 465? Or does it rely on any service to run sending emails?

Websites don’t send emails. A program that you run on or through your website might send emails.

So the requirements for sending email from/through your website depends on what program you’re using to send the emails.

What program are you using for that purpose?

May I ask what the purpose of your sending email is? Is it to send logs to yourself, or something else? The reason I ask is that the answer to your question depends on what you are doing.

For example, do I need the server to set up port clearance for sending via Gmail SMTP? Should I install postfix?

Notification sent to the email address of a member after registering on the website,

Again, you need more than just apache (httpd) to send email. You may click a button on the website that says “send email”, but that button calls a program (that’s not apache) to actually send the email.

So what program are you using or planning to use for that purpose? Or is that your question? If so, then what program are you running on your website that collects these registrations that you want to send an acknowledement for?

I have seen different solutions for this, depending on what software or libraries you use:

Some web software has a configuration dialog where you can specify a remote SMTP server and the software will send mails to this SMTP server ( most likely on port 25). This works if the SMTP server accepts incoming data from that host.

I have seen other solutions where you need to setup some local mail server to work as a mail relay. In that case the software is using some local mail client or talks to your local SMTP on localhost (port 25) and your local SMTP server is working as a mail relay and is forwarding the mails, most likely to the same remote SMTP server you would have used above.

If you create the web server software yourself, you can use any of the two options. You only have to pick a library that does the job for you.
( When I write scripts and tools, especially when they are running as a normal user, I prefer the first method as I do not depend on the setup of the local machine.)
There should be suitable libraries to do the job depending on the programming language your web server is using.

You will need some sort of mail server program (I would use postfix personally) to send your email. Keep in mind that when sending email, there are a LOT of caveats these days. Even if you have everything setup correctly, your receiving mail server may reject the email you send if you do not have a valid forward and reverse DNS entry as well as a long DNS time to live. (Generally at least 24 hours). As @Hedges says, you can configure your server to send to a local SMTP server that then forwards your email. This can be helpful if that server is already well established as a mail server and can easily send email to most domains without worry of rejection.

If it’s an option, I’d use an established local SMTP server as a relay, and setup your web server’s email to send to that server. That said, you still have to be very careful. A misconfiguration on your email service for your web server, could then open up a stream of spam to your established SMTP server and get your network IP blocked.

It is a delicate balancing act, and requires a good deal of research on your end to decide the best method. No one-size-fits-all exists. Good luck!

Thank you very much for your message. Currently, I also like the first method you mentioned. This way, there is no need to enable configuration on the server. Perhaps the reason why I am not successful at the moment is that port 25 is not open. In the Enforcing mode of Selinux, port 25 seems to be unable to start unless I need to install postfix to enable port 25. I don’t know what the problem is, maybe it’s a permission issue, or if there are any commands that can enable port 25 to be enabled in Enforcing mode without installing email services? thank you

Thank you for your message. If I can solve the problem without installing postfix at the moment, I won’t install it for now because I use very few email functions. I only send emails to notify customers when they register and place orders. If there are no other methods, I will consider installing postfix as a relay. Also, thank you for saying that we need to be careful with the configuration to avoid key errors. Thank you

[root@zhang ~]# getenforce
Enforcing
[root@zhang ~]# sudo systemctl start postfix
Job for postfix.service failed because the control process exited with error code.
See “systemctl status postfix.service” and “journalctl -xeu postfix.service” for details.
[root@zhang ~]# sudo systemctl status postfix
× postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Sun 2025-01-26 20:06:38 CST; 6s ago
Process: 1695 ExecStartPre=/usr/sbin/restorecon -R /var/spool/postfix/pid (code=exited, status=0/SUCCESS)
Process: 1696 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Process: 1698 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 1699 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
CPU: 3.031s

Jan 26 20:06:31 zhang systemd[1]: Starting Postfix Mail Transport Agent…
Jan 26 20:06:35 zhang postfix[1759]: find: ‘/var/spool/postfix/public’: Permission denied
Jan 26 20:06:35 zhang postfix/postfix-script[1765]: starting the Postfix mail system
Jan 26 20:06:35 zhang postfix/master[1767]: fatal: remove public/pickup: Permission denied
Jan 26 20:06:36 zhang postfix/master[1766]: fatal: daemon initialization failure
Jan 26 20:06:37 zhang postfix/postfix-script[1768]: fatal: mail system startup failed
Jan 26 20:06:38 zhang systemd[1]: postfix.service: Control process exited, code=exited, status=1/FAILURE
Jan 26 20:06:38 zhang systemd[1]: postfix.service: Failed with result ‘exit-code’.
Jan 26 20:06:38 zhang systemd[1]: Failed to start Postfix Mail Transport Agent.
Jan 26 20:06:38 zhang systemd[1]: postfix.service: Consumed 3.031s CPU time.

that is in Enforcing of Selinux, postfix can’t start.
how to start it? thanks.

What changes have you made to the postfix configuration? Does it start if you use the default configuration?

nothing change, just install it , can run in permissive and disabled of selinux . remove postfix and install it all the same can’t start.