Linux Postfix Mail Server devcote error

Can anyone review the below script and please let me know if I am making any mistakes…for me script seems fine but getting error at the end

#!/bin/bash

Update system packages

sudo yum update -y

Install Postfix

sudo yum install -y postfix

Configure Postfix

sudo postconf -e ‘home_mailbox = Maildir/’
sudo postconf -e ‘mail_spool_directory = /var/mail/’
sudo postconf -e ‘virtual_alias_maps = hash:/etc/postfix/virtual’
sudo postconf -e ‘virtual_mailbox_domains = hash:/etc/postfix/vmailbox_domains’
sudo postconf -e ‘virtual_mailbox_maps = hash:/etc/postfix/vmailbox’
sudo postconf -e ‘virtual_mailbox_base = /var/mail/vhosts’
sudo postconf -e ‘virtual_uid_maps = static:5000’
sudo postconf -e ‘virtual_gid_maps = static:5000’
sudo postconf -e ‘smtpd_banner = $myhostname ESMTP $mail_name’
sudo postconf -e ‘myhostname = stratos.xfusioncorp.com
sudo postconf -e ‘mydestination = localhost’
sudo postconf -e ‘relay_domains =’
sudo postconf -e ‘mynetworks = 127.0.0.0/8’
sudo postconf -e ‘inet_interfaces = all’

Create the user and set the password

sudo useradd kareem
echo ‘kareem:GyQkFRVNr3’ | sudo chpasswd

Set up the Maildir directory

sudo mkdir -p /home/kareem/Maildir
sudo chown -R kareem:kareem /home/kareem/Maildir
sudo chmod -R 700 /home/kareem/Maildir

Restart Postfix to apply the changes

sudo systemctl enable postfix
sudo systemctl restart postfix

Install Dovecot

sudo yum install -y dovecot

Configure Dovecot

sudo sed -i ‘s/^#mail_location =./mail_location = maildir:/home/%u/Maildir/’ /etc/dovecot/conf.d/10-mail.conf
sudo sed -i 's/^#user =.
/user = kareem/’ /etc/dovecot/conf.d/10-mail.conf

sudo sed -i ‘s/^#listen =.*/listen = *\n/’ /etc/dovecot/dovecot.conf
sudo sed -i ‘s/^#disable_plaintext_auth = yes/disable_plaintext_auth = no/’ /etc/dovecot/conf.d/10-auth.conf
sudo sed -i ‘s/^auth_mechanisms = plain/login/auth_mechanisms = plain login/’ /etc/dovecot/conf.d/10-auth.conf

sudo sed -i ‘s/^#ssl = required/ssl = no/’ /etc/dovecot/conf.d/10-ssl.conf

Restart Dovecot to apply the changes

sudo systemctl enable dovecot
sudo systemctl restart dovecot

echo “Postfix and Dovecot installation and configuration completed.”

Hello there !
I have done kind of the same thing, same steps in this video : https://youtu.be/kdcUfw5vJKY?si=6ZCSQPZd20_K-653 but didn’t work for me, but found another quicky way …

After doing all the steps in the video, except the testing using telnet command .

What i did is i monitored previous failing tasks to see the validation process, and i understand, that a validation mail is being sent, but the validation is not waiting for the mail to be received, so it fails before even the mail gets created under user_home/Maildir/new/ .

So, I copied the content of the validation mail, and used telnet to make a kind of validation mail so the process works and it is working actually !

the validation mail looks like this :

retr 2
+OK 545 octets
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: by stmail01.stratos.xfusioncorp.com (Postfix, from userid 1002)
        id 64EA96A8F572; Fri, 20 Sep 2024 23:01:43 +0000 (UTC)
Date: Fri, 20 Sep 2024 23:01:43 +0000
To: [email protected]
Subject: Welcome
User-Agent: s-nail v14.9.22
Message-Id: <[email protected]>
From: [email protected]

Welcome to xFusionCorp Industries

you can send this using telnet or send any mail and then update it using vim …