LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-18-2024, 06:59 PM   #1
djkori
LQ Newbie
 
Registered: Apr 2024
Location: Peru
Distribution: Mint & Debian
Posts: 2

Rep: Reputation: 0
Need help installing Postfix in Debian 11 server


Hello everybody, hope you're all ok.
Even if this is my first topic here, I'm not new in the linux world.
I can manage myself most of the times with the documentation and net searches but sometimes not, like this time and I'm sorry for that. I'm still an "amateur".
I just installed a new server, Debian 11 in a VPS and I need to send emails.
I use the services of a relay but I do not understand why I cannot make it work...
I have installed Postfix with ssl, certs, private keys, passwd, etc.
This is the /etc/postfix/main.cf
PHP Code:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner $myhostname ESMTP $mail_name (Debian/GNU)
biff no

# appending .domain is the MUA's job.
append_dot_mydomain no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level 2



# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file
=/etc/ssl/private/ssl-cert-snakeoil.key
#smtpd_tls_security_level=may

smtp_tls_CApath=/etc/ssl/certs
#smtp_tls_security_level=may
smtp_tls_session_cache_database btree:${data_directory}/smtp_scache


smtpd_relay_restrictions 
permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname 
server.ovh.net
alias_maps 
hash:/etc/aliases
alias_database 
hash:/etc/aliases
myorigin 
= /etc/mailname
mydestination 
$myhostnamedomain.comserver.ovh.netlocalhost.ovh.netlocalhost
relayhost 
= [smtp.netcorecloud.net]:587
mynetworks 
127.0.0.0/[::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit 
0
recipient_delimiter 
= +
inet_interfaces all
inet_protocols 
all

# Enable SASL authentication
smtp_sasl_auth_enable yes
smtp_sasl_security_options 
noanonymous
smtp_sasl_password_maps 
hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_security_level 
encrypt
smtp_tls_CAfile 
= /etc/ssl/certs/ca-certificates.crt
smtp_tls_cert_file 
= /etc/ssl/certs/server.crt
smtp_tls_key_file 
= /etc/ssl/private/server.key 
All the files /etc/ssl/certs/ssl-cert-snakeoil.pem, /etc/ssl/private/ssl-cert-snakeoil.key, /etc/ssl/certs/ca-certificates.crt, /etc/ssl/certs/server.crt, /etc/ssl/private/server.key are well placed, and the /etc/postfix/sasl/sasl_passwd is in place with the right data and postmaped ok.
The relayhost is well defined: relayhost = [smtp.netcorecloud.net]:587 and I have no firewall enabled to disturb.

But when I try to send a mail I have this log:
Quote:
Apr 19 01:32:17 server postfix/pickup[5253]: 6EE582028E: uid=0 from=<root>
Apr 19 01:32:17 server postfix/cleanup[5258]: 6EE582028E: message-id=<20240418233217.6EE582028E@server.ovh.net>
Apr 19 01:32:17 server postfix/qmgr[5254]: 6EE582028E: from=<root@domain.com>, size=280, nrcpt=1 (queue active)
Apr 19 01:32:17 server postfix/local[5260]: 6EE582028E: to=<mail.address@dom.com>, relay=local, delay=18, delays=18/0.01/0/0.02, dsn=5.1.1, status=bounced (unknown user: "mail.address")
Apr 19 01:32:17 server postfix/cleanup[5258]: 7A82B2028F: message-id=<20240418233217.7A82B2028F@server.ovh.net>
Apr 19 01:32:17 server postfix/qmgr[5254]: 7A82B2028F: from=<>, size=2205, nrcpt=1 (queue active)
Apr 19 01:32:17 server postfix/bounce[5261]: 6EE582028E: sender non-delivery notification: 7A82B2028F
Apr 19 01:32:17 server postfix/qmgr[5254]: 6EE582028E: removed
Apr 19 01:32:17 server postfix/local[5260]: 7A82B2028F: to=<root@domain.com>, relay=local, delay=0.01, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Apr 19 01:32:17 server postfix/qmgr[5254]: 7A82B2028F: removed
-> Postfix is working on local and refuse to send by smtp.
I think I should have to have this type of log, as I have in another server, using, curiouly the same configuration and the same relay:
Quote:
Apr 18 13:30:12 server postfix/pickup[257816]: D8A6AA1709: uid=33 from=<www-data>
Apr 18 13:30:12 server postfix/cleanup[258156]: D8A6AA1709: message-id=<20240418173012.D8A6AA1709@server.vps.ovh.ca>
Apr 18 13:30:12 server postfix/qmgr[204252]: D8A6AA1709: from=<www-data@pukanina.asouka.com>, size=6206, nrcpt=2 (queue active)
Apr 18 13:30:13 server postfix/smtp[258158]: D8A6AA1709: to=<mail.address@dom.com>, relay=smtp.netcorecloud.net[35.212.37.142]:587, delay=0.41, delays=0.02/0.03/0.32/0.04, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as A83F62A0004)
Apr 18 13:30:13 server postfix/smtp[258158]: D8A6AA1709: to=<pat.boye31@yahoo.fr>, relay=smtp.netcorecloud.net[35.212.37.142]:587, delay=0.41, delays=0.02/0.03/0.32/0.04, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as A83F62A0004)
Apr 18 13:30:13 server postfix/qmgr[204252]: D8A6AA1709: removed
I really do not understand
 
Old 04-19-2024, 03:08 PM   #2
blunix2
LQ Newbie
 
Registered: Apr 2024
Posts: 12

Rep: Reputation: 1
Welcome to Postfix It IS hard to understand. Postfix takes quite a bit of getting used to. For very large mailservers (thousands of users) I would still use Postfix. Otherwise I would, by now, recommend OpenSMTPD, which is MUCH simpler to configure.

I am happy to help you with both, or point you to the right solution, depending on what your goal is.

Your post is a bit confusing:

> I use the services of a relay but I do not understand why I cannot make it work...

That sounds like you want to relay emails to a large provider (gmail) which then delivers it to the final recipient.

> From your config: `permit_sasl_authenticated`

This looks like you are trying to "setup a mailserver" - a server "mail.example.com" where you can SMTP auth with your thunderbird mail client and "send mails".

Which one is it?
 
Old 04-20-2024, 12:13 PM   #3
djkori
LQ Newbie
 
Registered: Apr 2024
Location: Peru
Distribution: Mint & Debian
Posts: 2

Original Poster
Rep: Reputation: 0
Hello blunix2,
Thanks for the reply,
I have several web sites, one is an extranet witch send automated mails for my clients, providers or even to my team, and I want to be sure that the mails sended arrive ok to the inboxes, so I decided some years ago to take the services of a relay to be sure that all my emails could arrive ok and not be bounced, rejected, placed on spam folder, etc.
I have a server with postfix configured with this relay, and all works ok and I had to reinstall the other server and reinstall all the applications, firewall, etc, and one of these is postfix.
In fact, I just want my server to send emails through this relay, if this is ok with postfix that's ok for me bue I'm opened to other solutions.
I see that you're talking about OpenSMTPD, I did not know. I'm go to see it now.
 
Old 04-20-2024, 04:24 PM   #4
blunix2
LQ Newbie
 
Registered: Apr 2024
Posts: 12

Rep: Reputation: 1
I'm not sure I fully understand your approach - but here is mine.

I host a larger number of websites, most of which generate emails like booking confirmations, newsletters and alike.

Each webserver (there are usually a larger number of web-servers (running nginx+php-fpm or something like this) behind a loadbalancer) has a local OpenSMTPD server installed - you can do this with Postfix too but the configuration is much more ugly (imho), which invites errors (readability counts, from the Zen of Python)

So these programs (Postfix or OpenSMTPD) installed on webservers are whats commonly referred to as a mailrelay. On this mailrelay, you setup SMTP credentials for a larger provider, like gmail or office365, the same way you would setup SMTP credentials in your thunderbird to send mails.

Your webapplication then gives all mails to localhost:25. Depending on the mail-from address your webapplication sets, OpenSMTPD (or Postfix) will choose one of the SMTP accounts you setup to relay the email.

This way makes sure that mails don't get lost, because everyone takes mails from gmail and other large players.

I have recently written an elaborate blogpost on the topic, which explains in detail how to setup a Mailrelay using OpenSMTPD to relay mails from your server to large providers like gmail. I'd recommend you to look through it - you can (almost) copy paste all of the code boxes and you should be good to go.

Let me know if it'll solve your problem.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix 2.6.6 postfix/cleanup and postfix/master errors Pummelmuffin Linux - Server 2 11-22-2020 12:50 PM
disclaimer addition on PostFix (relay server) error comes fatal: /etc/postfix/master.cf: line 12: bad transport type: content_filter=dfilt: fahasida Linux - Newbie 1 07-17-2017 07:20 AM
Postfix: postfix: fatal: chdir(/usr/libexec/postfix) Micro420 Ubuntu 2 07-13-2008 12:21 PM
Postfix Configuration Question: Postfix server as a catch-all on office LAN enso491 Linux - Server 5 04-14-2008 04:35 PM
move postfix mails from server to another postfix server onetwo Linux - Software 2 03-18-2003 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration