1

Topic: Unable to send emails from google using SMTP

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9 PGSQL edition.
- Deployed with iRedMail Easy or the downloadable installer? Yes
- Linux/BSD distribution name and version: Debian GNU/Linux 9 (stretch)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello,

We're trying to connect a Gmail account to an account in our server, but Gmail says that is unable to connect and I've to check the server and port:
https://i.imgur.com/l6pcN1c.png

I've tried port 25 and also 465 (but this port is disabled on server config, so it's not usefull). I'm able to connect to SMTP using thunderbird and same configuration (mail host, port, and STARTTLS), but not using port 25 so looks like there's something configured to foce user to use secure connection (that don't really cares and is better to keep it).
Also I've tested the SSL cert using this command:
openssl s_client -starttls smtp -showcerts -connect mail.host:587

and certificate is right.

I'd like to provide any logs, but I don't know how to filter the tons of logs I've got on server to find anything usefull.
Can someone help me to find/debug this problem?.

Thanks!!

2

Re: Unable to send emails from google using SMTP

Try to stop "fail2ban" service on your iRedMail server, then try again.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

3 (edited by d.carrasco 2019-03-08 18:36:41)

Re: Unable to send emails from google using SMTP

Hello,

Thanks for your response.
I've disabled the fail2ban but the problem still there. Also yesterday I did a check of all the IP addresses that were on IPTables and none of them were from google.

I've changed the password two times and both worked fine on Roundcube, but same problem on Google.

I'm able to send and receive mails without problems and also I can see how Google MX are connecting to our server (and our server to their MX), so is not a DNS problem or firewall limitation.

Thanks!!

4

Re: Unable to send emails from google using SMTP

When You say_ "connect an GMAIL account to an account in our server", what do you mean?
1) send email from an account in GMAIL to an account in iRedMAIL?
2) use some of the Google functions, which one?: Import Mail,Check mail from other account , POP download, Something else?

For the logfile, just cut and paste the /var/log/mail when you try to connect from google. There must be ome kind of errors related to what kind of operation you are trying.
Note: port 587 is used for Authenticated SMTP (login credentials needed, i.e. an existing user in iRedMail) port 25 is for inbound SMTP messages (to local users only)

" but Gmail says that is unable to connect"
What is the exact message?


d.carrasco wrote:

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9 PGSQL edition.
- Deployed with iRedMail Easy or the downloadable installer? Yes
- Linux/BSD distribution name and version: Debian GNU/Linux 9 (stretch)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello,

We're trying to connect a Gmail account to an account in our server, but Gmail says that is unable to connect and I've to check the server and port:
https://i.imgur.com/l6pcN1c.png

I've tried port 25 and also 465 (but this port is disabled on server config, so it's not usefull). I'm able to connect to SMTP using thunderbird and same configuration (mail host, port, and STARTTLS), but not using port 25 so looks like there's something configured to foce user to use secure connection (that don't really cares and is better to keep it).
Also I've tested the SSL cert using this command:
openssl s_client -starttls smtp -showcerts -connect mail.host:587

and certificate is right.

I'd like to provide any logs, but I don't know how to filter the tons of logs I've got on server to find anything usefull.
Can someone help me to find/debug this problem?.

Thanks!!

5 (edited by d.carrasco 2019-03-08 22:43:58)

Re: Unable to send emails from google using SMTP

Hello,

I mean send emails from Gmail, using SMTP connection to our server (configure an external account using SMTP). I'm using an existing account that can login in using roundcube, and also Thunderbird to same port.
Between Gmail and our server I can send emails without problem, is just the SMTP authentication.

About the log... I've not found anything significant about the problem in log and that's why I'm not able to debug the problem. Monday I'll try to extract a part and post it.

Thanks!!

6 (edited by swejun 2019-03-12 19:06:44)

Re: Unable to send emails from google using SMTP

OK, my spanish is not what it used to be ... So I understand that you are using the feature in GMail referred to as "Send mail as..." which configures the Gmail account with SMTP Auth login to Your iRedMail instance.
I did the same (works OK) and this is what happend:
1) defining the login credentials and the mail server name: an email is send to the mailbox to confirm
2) sending an email from GMAIL using the IredMail account name as sender:

the /var/log/maillog shows the conenction from GMAIL, login and the posting of a message. /this is what you should look for in the logfile)

Mar 12 11:50:27 mail2 postfix/submission/smtpd[29591]: connect from mail-it1-f181.google.com[209.85.166.181]
Mar 12 11:50:28 mail2 postfix/submission/smtpd[29591]: Anonymous TLS connection established from mail-it1-f181.google.com[209.85.166.181]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Mar 12 11:50:28 mail2 postfix/submission/smtpd[29591]: D368E138FA9: client=mail-it1-f181.google.com[209.85.166.181], sasl_method=PLAIN, sasl_username=MyMailAddress@MyDomain.TLD
Mar 12 11:50:29 mail2 postfix/cleanup[29286]: D368E138FA9: message-id=<CAAn541w0keNfiTxygny6+2C-aAdyRoS=TSgkz=VsSgGAt8SoJw@mail.gmail.com>
Mar 12 11:50:29 mail2 postfix/qmgr[5737]: D368E138FA9: from=<MyMailAddress@MyDomain.TLD>, size=1424, nrcpt=1 (queue active)
Mar 12 11:50:29 mail2 postfix/submission/smtpd[29591]: disconnect from mail-it1-f181.google.com[209.85.166.181]

If you can't find anything in the logfile that relates to login from google using the submission port, then you have not configured the correct mailserver name.

7

Re: Unable to send emails from google using SMTP

Hello,

I've tried several things to make it work and nothing works... I can't see the login attempt so there's no connection, and even I've tried to use an HAProxy proxy to connect through another server that is located in GCP infraestructure, and like all the tests before, Thunderbird is able to send emails through real server and HAProxy server, but Google is unable to connect to both.

About the correct mailserver name: ¿you mean the server name in smtp configuration?, because I'm 100% sure that is right and even I've tried directly the IP address (on thunderbird works with all the ways I've tried).

Thanks!!

8 (edited by d.carrasco 2019-03-13 17:09:17)

Re: Unable to send emails from google using SMTP

Hello,

Finally I've found the problem thanks to another problem we have. Thundebird configuration was fine but because it has more patience waiting for SMTP connection than Google, so it keeps waiting until connection is done. Google don't wait too much so it just give a "cannot connect" message.
After researching why the smtp connection can be slow I've found another post in this forum talking about the DNS resolution in server (resolv.conf). I've checked that file and susprise!!, the file is wrong and points first to localhost (too bad for the cloud provider), so the dns resolution is slow and make the SMTP connection slow too.

I never would have thought that the problem was just DNS resolv, because I've done a lot of things in that server like update and download packages and I've not noticed slow resolutions until I've checked it manually with dig.

Finally I've fixed two problems in one.

Thanks for all your help!.

9

Re: Unable to send emails from google using SMTP

I'm glad you fixed it. This was a very interesting problem and solutions. Will keep it in mind (and I checked my resolve.conf as well, just to be sure...)

10

Re: Unable to send emails from google using SMTP

d.carrasco wrote:

After researching why the smtp connection can be slow I've found another post in this forum talking about the DNS resolution in server (resolv.conf). I've checked that file and susprise!!, the file is wrong and points first to localhost (too bad for the cloud provider), so the dns resolution is slow and make the SMTP connection slow too.

It's very possible that your system was using the DNS service provided by systemd-resolved.
FYI: https://www.freedesktop.org/software/sy … rvice.html

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee