Rainroop can send and receive E-mail but not PHP script are unable to

I can send and receive emails through Rainloop. When I add the same credentials to any php script I get the following error

Debugged data:

2022-04-22 01:50:11 CLIENT → SERVER: EHLO Mydomian.com

2022-04-22 01:50:11 CLIENT → SERVER: STARTTLS

SMTP Error: Could not connect to SMTP host.

2022-04-22 01:50:11 CLIENT → SERVER: QUIT

2022-04-22 01:50:11

SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

How can I resolve this? These scripts used to send emails but of late they can’t. One of the applications is NextCloud the other uses PHPMailer . Any help will be apreciated

what is the results of //email/testTo:

Thanks for the link. I think the problem is the self-signed certificate.

Certificate #1 of 1 (sent by MX):

Cert VALIDATION ERROR(S): self signed certificate
The email is encrypted but the recipient domain is not verified

Resolved, I have realised I also needed to delete the email subdomain /child domain. reissue the certificate and run the following command

postmap -F hash:/etc/postfix/vmail_ssl.map
systemctl restart postfix
systemctl restart dovecot

Thanks Everyone