Cant connect SMTP

Explain how this is not working? You just showed us 2 emails that where sent successfully to gmail.

You need to ask your provider if they support giving you an rDNS/PTR for the ipv6 they gave you.
Than add the ipv6 to your DNS AAAA Records. You should be good to go.

I have a website (herbsofafrica.com) built with Laravel. In the env file, I placed the mail configurations there so that I can generate emails from the server to user’s email
MAIL_MAILER=smtp
MAIL_HOST=herbsofafrica.com
MAIL_PORT=587
MAIL_USERNAME=support@herbsofafrica.com
MAIL_PASSWORD=myemailpassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=support@herbsofafrica.com
MAIL_FROM_NAME=“${APP_NAME}”

This is what I get:

Connection could not be established with host “herbsofafrica.com:587”: stream_socket_client(): Unable to connect to herbsofafrica.com:587 (A connection attempt failed because the connected party did not properly respond after a period.

Then I tried using OUTLOOK with the same credentials, and it gives me error also

Concerning rDNS/PTR for the ipv6, is this what you mean ?
I found this in my server domain record. Not sure how to use it.
I am also using cloudflare for DNS.

This has to be a user setup on the Virtualserver account. Just go into email settings on Virtualmin for this account and create a user that will be able to have access to email functions. You can create a user for that account with any name and give it the alias for support@yourdomain.

Yes! you can set that and ipv4 to point to your server hostname that postfix uses and you should be good.

please i’m sorry, don’t be offended. I don’t know how to do this and also where to do it.
is it on cloudflare, or on my server, or both. And How ?

The RDNS gets setup with whomever is your IP provider for the server. You give them your postfix hostname.
If cloudflare is your DNS provider for your domain name? Than set up the ipv4 and ipv6 to point to your postfix hostname.

Please based on the information I have shared so far,
Please tell me which goes in where ?

This is cloudflare.
What should I put in TYPE, NAME, and DOMAIN NAME

Also is there any other setting required ?

Does cloudflare provide the IP for your server? Only enter PTR if they do.
Other wise, make sure you have an A record for your hostname and AAAA record for your hostname in cloudflare.

If cloudflare DOES NOT provide the IP for your server? Than contact support for whomever does.
Ask the IP provider to create a rDNS/PTR for your hostname.

Also, Don’t forget to follow instructions above about setting MAIL_USERNAME=
This has to be a user on that Virtualserver.

Linode is the one providing the IP address for my server.
The picture I sent earlier showing ipaddress and reverse dns, was on linode.

I will go ahead to ask Linode to create a rDNS/PTR for my hostname.
I also see that I already have A records and AAAA records set on cloudflare.

1 Like

concerning the instruction to ensure the mail_username is a user

it was already a user on the machine, but with only Email Login Access.
Now I enabled other login access as shown in the image below

You’ve mentioned at least two different problems here.

Title is “can’t connect SMTP”. What can’t connect to SMTP? Is that when you try to connect using a mail client like Thunderbird or Outlook? That would be explained by the authentication error in the log you included. So, make sure you’re using the actual full username (the default is user@domain.tld and not just user). You can find the exact username on the Edit Users page. Also, obviously, the password much be right.

This one we may not be able to answer. I don’t know how to troubleshoot why GMail considers something spam
it may just look like spam to Google, even if all the technicals are right. Does a simple test email make it through?

Note this is unrelated to your authentication error.

A step by step guide to what, specifically?

We have this guide for troubleshooting various issues with mail: Troubleshooting Emails | Virtualmin — Open Source Web Hosting Control Panel

Well you removed the information about your setup preferences for the script to access your email server. I suggest like someone had mentioned above to recheck the settings and make sure your entered to right credentials.

This is the settings you are referring to right?

This username and password (hidden) are correct. I use it to login to usermin and it works, I use it to login to roundcube and it works.
But its not working for SMTP connection.

setup

What happens if you use STARTTLS for MAIL_ENCRYPTION=

just tried that

still got this:

Connection could not be established with host “herbsofafrica.com:587”: stream_socket_client(): Unable to connect to herbsofafrica.com:587 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

Change the MAIL_HOST as well to postfix hostname. or even mail.yourdomain if you have that setup in your DNS already.

@Joe @cyberndt
I tried this in the test, replacing user and pass with my user and password
testsaslauthd -u user -p pass -s smtp

and I got this
connect() : No such file or directory

$ nmap herbsofafrica.com
Starting Nmap 7.95 ( https://nmap.org ) at 2024-06-03 15:50 CDT
Nmap scan report for herbsofafrica.com (172.67.149.107)
Host is up (0.021s latency).
Other addresses for herbsofafrica.com (not scanned): 104.21.29.153 2606:4700:3032::6815:1d99 2606:4700:3030::ac43:956b
Not shown: 996 filtered tcp ports (no-response)
PORT     STATE SERVICE
80/tcp   open  http
443/tcp  open  https
8080/tcp open  http-proxy
8443/tcp open  https-alt

Nmap done: 1 IP address (1 host up) scanned in 5.14 seconds

You only have a handful of ports open, and they don’t include any of the mail ports.

Are you behind Cloudflare or some other proxy thing or are you on a network connection that otherwise blocks mail ports? If so, you need to make that not so for mail addresses. You can’t run mail through Cloudflare (and you can’t run mail on a consumer network connection or on some cloud providers without jumping through some additional hoops).