-2
  1. I have a VPS server
  2. I have a postfix mail server running on that VPS server (I installed it via command line using a tutorial)
  3. I have an SMTP server running on that VPS server
  4. I also have the required records for mail server such as, (MX record, SPF record, PTR record, DMARC record, A record) I checked them out via: mxtoolbox checker and I got all of them correct

But unfortunately, still I can not send or receive mails whether I was using:

  1. usermin (port:20000)
  2. or even from my website using PHPMailer library

my Postfix configuration file is:

# 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 (Ubuntu)
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_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mainserver.mskillsa.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mskillsa.com, mainserver.mskillsa.com, localhost.mskillsa.com, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtp_sasl_auth_enable = yes

My Domain Name is: mskillsa.com

My Hostname is : mainserver.mskillsa.com

My Email is : info@mskillsa.com

Some record checkers told me that I do not have DKIM record, I tried to use third party DKIM record generator and I use it but STILL have the same issue with DKIM record!!!

My PHPMailer codes :

<?php

// Include required phpmailer files

require "includes/PHPMailer.php";
require "includes/SMTP.php";
require "includes/Exception.php";
// Define name spaces

use PHPMailer\PHPMailer\PHPMailer;

use PHPMailer\PHPMailer\SMTP;

use PHPMailer\PHPMailer\Exception;

// Create instance of phpmailer

$mail = new PHPMailer();

// Set mailer to use SMTP

$mail->isSMTP();

// Define SMTP host

$mail->Host = "mail.mskillsa.com";

// enable SMTP authentication

$mail->SMTPAuth = "true";

// Set type of encryption (ssl/tls)

$mail->SMTPSecure = "ssl";

// Set port to connect SMTP

$mail->Port = "465";

// Set username

$mail->Username = "example@mskillsa.com";

// Set password

$mail->Password = "password";

// Set email Subject

$mail->Subject = "Hello Info Testing";

// Set sender email

$mail->setFrom("example@mskillsa.com");

// Email Body

$mail->Body = "Hello testing...";

// Add recipient

$mail->addAddress('recipient_example@gmail.com');

// Finally Send Email

if ($mail->send()) {
    echo "Sent";
} else {
    echo "Not Sent";
}

// Closing SMTP Connection

$mail->smtpClose();

And I got the following error:

2022-08-08 15:42:54 CLIENT -> SERVER: EHLO mskillsa.com
2022-08-08 15:42:54 CLIENT -> SERVER: STARTTLS
SMTP Error: Could not connect to SMTP host. Connection failed. stream_socket_enable_crypto(): Peer certificate CN=`localhost.localdomain' did not match expected CN=`mainserver.mskillsa.com'
2022-08-08 15:42:54 CLIENT -> SERVER: QUIT
2022-08-08 15:42:54
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Not Sent

My master.cf file:

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd
#smtp      inet  n       -       y       -       1       postscreen
#smtpd     pass  -       -       y       -       -       smtpd
#dnsblog   unix  -       -       y       -       0       dnsblog
#tlsproxy  unix  -       -       y       -       0       tlsproxy
#submission inet n       -       y       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_tls_auth_only=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       y       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       y       -       -       qmqpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
        -o syslog_name=postfix/$service_name
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -   n   n   -   2   pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

I tested my email score in https://www.mail-tester.com/ and you can check my score

  • When I try to integrate (connect) to gmail I get the following error: Couldn't reach server. Please double-check the server and port number. – Mohammed Fahd Aug 06 '22 at 19:20
  • Postfix **is** a SMTP server. What SMTP server are you talking about in point 3? What is client and what is server in the error message you quoted? Looks like the server tries to verify the certificate of the client, which is NOT a common practice in configuration of SMTP servers (generally certs are NOT verified). I don't see this setting in your Postfix config, so it must be the "other" SMTP server that is requiring this. What is that server and why do you use two mail servers at all? – raj Aug 06 '22 at 19:52
  • Also, why do you use `smtp_sasl_auth_enable=yes`? To what server are you trying to authenticate when sending mail? Where are the authentication credentials configured? – raj Aug 06 '22 at 19:54
  • Thanks for replying, First of all, I have one mail server which is postfix. I do not have two mail servers. – Mohammed Fahd Aug 06 '22 at 22:23
  • secondly, (The server and The client that were mentioned in the error message) I just do not know about them. Just, I got this error when i tried to send a mail using PHPMailer library – Mohammed Fahd Aug 06 '22 at 22:37
  • Start with something simple. Does it work when you just try to send mail using `mail` application from command line? And instead of that error dialog you posted, check postfix logs - they will tell you much more what's going on. – raj Aug 06 '22 at 22:42
  • yes, it sends from command line using the mail command – Mohammed Fahd Aug 07 '22 at 00:33
  • When I send an email using Command Line I receive it in my gmail account correctly, But, When I send an email from usermin interface (using my domain email) to gmail sometimes i get it and sometimes not – Mohammed Fahd Aug 07 '22 at 00:46
  • 1
    Please post your PHP configuration part regarding to sending mail. If `mail` command is sending mail properly, then probably if PHP would use directly sendmail submission (as it should) and not SMTP connection to localhost, it would also send mail properly. So you should fix your PHP configuration. – raj Aug 08 '22 at 09:30
  • When I send a mail using PHP mail function it sends correctly, BUT when I use the PHPMailer library I can not send using it – Mohammed Fahd Aug 08 '22 at 14:16
  • PHPmailer does too many complicated things that are usually unnecessary for just sending mail. Please post the parameters you are using for calling PHPmailer. They probably need to be adjusted to connect to your server. – raj Aug 08 '22 at 14:22
  • Thanks for replying, I posted my phpmailer file above in the question section, you could see it – Mohammed Fahd Aug 08 '22 at 15:23

1 Answers1

0

You overcomplicate things when using PHPmailer.

As your SMTP server is on localhost, the simplest thing you can do is not to use $mail->isSMTP() at all and not to set any values for $mail->Host, $mail->SMTPAuth, $mail->SMTPSecure, $mail->Port, $mail->Username and $mail->Password. Omit $mail->smtpClose() as well. So you are left with

$mail = new PHPMailer();
$mail->Subject = "Hello Info Testing";
$mail->setFrom("example@mskillsa.com");
$mail->Body = "Hello testing...";
$mail->addAddress('recipient_example@gmail.com');

if ($mail->send()) {
    echo "Sent";
} else {
    echo "Not Sent";
}

like in the first example from this tutorial ("How to send your first email with PHPmailer").

With this approach, PHPmailer will use exactly the same method of sending mail as PHP internal mail() function, that is, submit the mail directly to local mail server using sendmail. In my opinion, it's the most proper method of sending mail on a machine that also runs a local SMTP server. If this method did work for you previously (mail from command line and PHP mail() function), it should work here too.

If you, however, insist on using SMTP, there are a few options how you can do that, but each of them requires some corrections to your parameters.

First, you attempt to use secure connection to local server ($mail->SMTPSecure = "ssl"). This gives absolutely no security benefits if you are connecting to localhost, and this is the main cause of your problems because the error dialog you posted shows that PHPmailer fails on certificate verification. So first try getting rid of encryption completely. Replace

$mail->Host = "mail.mskillsa.com";

by

$mail->Host = "localhost";

or

$mail->Host = "127.0.0.1";

and remove the line $mail->SMTPSecure = "ssl". You may also need to add the following:

$mail->SMTPAutoTLS = false;

to stop PHPmailer from automatically using encryption if it sees that server supports it.

Because your Postfix server trusts localhost (which is absolutely correct) - the localhost address is included in mynetworks=. So you can simply connect to standard SMTP port 25. You should also get rid of authentication, because your current Postfix configuration does not support authentication, at least on port 25 (you did not post your master.cf, where the configuration for submission service on port 465 is probably defined, so I don't know for sure if authentication is supported there or not, but from the dialog you posted - the previous version, before your editing - I see that the server does not advertise AUTH). So remove $mail->SMTPAuth, $mail->Username and $mail->Password lines, and set

$mail->Port = 25;

So next option that works should be the following:

$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "localhost";
$mail->SMTPAutoTLS = false;
$mail->Port = 25;
$mail->Subject = "Hello Info Testing";
$mail->setFrom("example@mskillsa.com");
$mail->Body = "Hello testing...";
$mail->addAddress('recipient_example@gmail.com');

if ($mail->send()) {
    echo "Sent";
} else {
    echo "Not Sent";
}

$mail->smtpClose();

Finally, if you really want to use encrypted authenticated submission (although I want to stress once again that it has no sense when connecting to local SMTP server), you need to fix a bit your Postfix configuration as well.

As I said, your Postfix configuration does not turn on authentication. You probably wanted to turn it on using the line smtp_sasl_auth_enable = yes, but this turns on authentication for Postfix connecting as a client to another server to send mail to it, and not for SMTP server in Postfix. You usually don't want this. And without an accompanying parameter smtp_sasl_password_maps, defining the credentials Postfix should use to authenticate to remote servers, this parameter does not work at all. So remove this line from your main.cf.

The parameter that turns on authentication in Postfix server is smtpd_sasl_auth_enable = yes (note the "d" in the name), but you should not put this in your main.cf as it isn't a good practice in configuring mail servers to enable authentication on port 25. Instead, you should enable authentication only in your submission service on port 465, which is defined in master.cf. You haven't posted your master.cf so I can't tell you how to correct it.

Assume you have fixed your master.cf, there are still some things needed to fix in your PHPmailer parameters. PHPmailer failed on certificate verification because you have a self-signed certfificate on your server and PHPmailer by default expects an "official" certificate from a certification authority and tries to verify it. So in addition to what you already have in your PHPmailer code, you need to add the following:

/* Disable some SSL checks. */
$mail->SMTPOptions = array(
   'ssl' => array(
   'verify_peer' => false,
   'verify_peer_name' => false,
   'allow_self_signed' => true
   )
);

I took this from the tutorial I already linked, see the second example under "How to use a custom SMTP server". This is a third variant that should work for you.

Update: Now that you posted your master.cf contents, I see that you don't have the submission service enabled at all. So I wonder how initially the connection to port 465 (as specified in your PHPmailer code) did work at all for you. Do you have some other software running on port 465? Because according to your master.cf, Postfix listens only on port 25.

Anyway, to make authenticated submission work, you need to uncomment the following lines in your master.cf and restart Postfix:

#smtps     inet  n       -       y       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING

But, you need also some authenticator defined that will check the users credentials. This is some program external to Postfix, such as for example Dovecot. You need to configure the authentication in two places. First, you need to add the following to your Postfix main.cf file:

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

Then, you need to configure in Dovecot an authentication service for Postfix. There is a tutorial on Dovecot website how to do that.

raj
  • 542
  • 2
  • 8
  • Thank you very much for your help and support, I will apply the solution, then i will update you – Mohammed Fahd Aug 08 '22 at 16:35
  • After I did all steps of your amazing solution, it sent correctly from phpmailer to gmail. Then I tried to use my usermin(port:20000) also sent to gmail correctly for only 3 times, after that, gmail did not receive. Do you Think there is some kind of limitation on the number of emails that I send? – Mohammed Fahd Aug 08 '22 at 17:37
  • There is another issue, My server can not receive mails at all!!! Although I have MX record for mail.mskillsa.com – Mohammed Fahd Aug 08 '22 at 17:39
  • Do I need to replace my SELF-SIGNED certificate with another valid SSL certificate (By PURCHASING one)to build authentication with another servers – Mohammed Fahd Aug 08 '22 at 17:51
  • Thank you for helping me, I REALLY REALLY appreciate it – Mohammed Fahd Aug 08 '22 at 17:56
  • As for receiving mail, you need to check your Postfix logs to see what is the problem. Also look at the reject message you are receiving. One possible issue may be that you don't have `mail.mskillsa.com` in your `mydestination=` list, so if you send to that domain, the server will not accept mail. As for the certificate, mail usually operates perfectly well with self-signed certs, so you don't need to purchase one. Ah, and I see that you don't have submission enabled at all in `master.cf`, so I wonder how the connection to port 465 did work... – raj Aug 08 '22 at 19:39
  • Also I tried to send a test email to `info@mskillsa.com` and your server replied that there is no such user. – raj Aug 08 '22 at 19:42
  • As for receiving mail, First Of All, My Postfix Logs does not have any Problem About Receiving (IT IS EMPTY), Secondly, I added `mail.mskillsa.com` to `mydestination=` list and STILL can not receive mails – Mohammed Fahd Aug 09 '22 at 15:20
  • When I send a mail from Gmail to my domain email `info@mskillsa.com` I get like a bounce email saying That `There is NO SUCH USER`, How can i Solve This???, For Your Information, I CAN SEND MAILS CORRECTLY USING MY OWN SERVER (from Inside my website php, or using usermin interface or roundcube interface) – Mohammed Fahd Aug 09 '22 at 15:23
  • How Can I Add submission to `master.cf` file? – Mohammed Fahd Aug 09 '22 at 15:25
  • 1) I added to my answer a description how to enable submission. 2) How can your Postfix log be empty if there is a reject with "user not exist" message? That reject should be logged. If log is empty, then maybe your server is NOT properly set as MX for the domain? Are mails sent from your server logged? – raj Aug 09 '22 at 15:57
  • Right now, when I try to check the names `mail.mskillsa.com` or `mainserver.mskillsa.com` in the DNS, I get a reply that this name does not exist. Yesterday, when I tried to send mail to you, it resolved to IP address `45.82.73.195`. Did you change something? – raj Aug 09 '22 at 16:02
  • Could you please let me know if I am correct in adding the following mail.mskillsa.com and mainserver.mskillsa.com in DNS records as A records which point to my IP adderss? – Mohammed Fahd Aug 09 '22 at 17:16
  • Yes, now they both resolve to `45.82.73.195`. – raj Aug 09 '22 at 17:23
  • Should I enable `smtpd_sasl_auth_enable = yes` in `main.cf` because I see in the tutorial you posted it's enabled???? – Mohammed Fahd Aug 09 '22 at 17:28
  • When I runned this command `postconf -a` I Got `cyrus` `dovecot` – Mohammed Fahd Aug 09 '22 at 17:32
  • I have a Question, Why Should I enable authenticated submission?? – Mohammed Fahd Aug 09 '22 at 17:36
  • For your Information, My server does not work on port 465 or 587, The only port that is working 25 – Mohammed Fahd Aug 09 '22 at 17:38
  • 1- I uncommented the lines you specified in `master.cf` file 2- I added the two lines you specified in `main.cf` file. What Should I do next? – Mohammed Fahd Aug 09 '22 at 17:51
  • I know that I bothered you, Sorry for that, Where Should I PUT my DKIM Private key? becuase when I send a message to gmail for example and show the original message by gmail I get SPF, DMARC records pass but DKIM failed – Mohammed Fahd Aug 09 '22 at 18:06
  • What should I SET the value of the MX record to ? (mail.mskillsa.com or mainserver.mskillsa.com)??? – Mohammed Fahd Aug 10 '22 at 00:02
  • Before doing the solution in the tutorial you posted, I was able to send but no receive, After doing the solution of the tutorial you posted I was not able to send or receive, BUT NOW I canceled the solution of the tutorial and IT WORKED correctly for sending – Mohammed Fahd Aug 10 '22 at 00:05
  • Ah, I FOUND MY POSTFIX LOG FILE WHICH IS HERE YOU COULD SEE IT: https://mskillsa.com/mail-log.txt – Mohammed Fahd Aug 10 '22 at 00:21
  • Also HERE IS THE MAIL ERROR FILE YOU COULD SEE IT: https://mskillsa.com/mail-error.txt – Mohammed Fahd Aug 10 '22 at 00:34
  • HERE IS POSTFIX MAIL LOG 1 file : https://mskillsa.com/mail-log-1.txt – Mohammed Fahd Aug 10 '22 at 00:48
  • You are trying to do too many things at once. I gave you a very detailed and multi-variant solution. You don't need to implement every variant. You need to implement only what you actually need. From your log I see that you have trouble configuring authentication. If you don't need authenticated submission (and you don't need it actually), then just don't enable it if you don't know how to do it and mostly important - if you don't know how to debug it. Stick to what works. Please read again **thoroughly** and **with understanding** my solution before you do anything. – raj Aug 10 '22 at 09:27
  • From what I see in your log, there are error messages regarding incorrect parameter `smtp_sasl_auth_enable = yes`. I told you to remove it. There are also error messages regarding to Postfix not being able to connect to OpenDKIM due to OpenDKIM not working. Fix this. Don't ask me how, because I don't know, you must debug it by yourself, it's your system. Start with getting **minimum working configuration** that sends and receives mail. Remove all references to DKIM etc. You can add all the fancy things later once the basics are working. – raj Aug 10 '22 at 09:36
  • I again tried to send mail to your server and your server sent me a bounce that the user does not exist. I see in your logs that the user `info@mskillsa.com` is able to successfully login to Dovecot. So you must have users defined differently in Dovecot and in Postfix and Postfix does not recognize Dovecot users. You must define them in the same way in both programs. Not knowing details of your Dovecot config, I can't help you further. – raj Aug 10 '22 at 09:46
  • It is also wrong that your server sends bounces instead of rejecting mail. Previously when I try to send you mail it was rejected, not bounced. Return to that configuration. Do one thing a time and understand what you're doing. If you don't understand, learn. Configuring a mailserver is quite complicated and you cannot expect that just following blindly some recipe, without understanding what it's actually doing and how the things are working, will give you satisfying results. Start from this: http://www.postfix.org/documentation.html and read "Basic configuration". – raj Aug 10 '22 at 09:49
  • Ok, Thank you for your help. You are right I should learn first – Mohammed Fahd Aug 11 '22 at 14:41
  • I have read https://www.postfix.org/BASIC_CONFIGURATION_README.html and understood some things – Mohammed Fahd Aug 11 '22 at 14:42
  • Yesterday, I've set SPF, DKIM, DMARC records successfuly, I checked them out in mxtoolbox and I sent a mail to gmail and showed the original form of the message and got all those records right, also checked them in dnschecker.org and also i got them right – Mohammed Fahd Aug 11 '22 at 14:49
  • Now, I have (A, PTR, SPF, MX, DMARC, DKIM) records – Mohammed Fahd Aug 11 '22 at 14:51
  • You can check out my score above via the last image I uploaded – Mohammed Fahd Aug 11 '22 at 15:13