Author Topic: Can't connect to smtp (postfix) via SSL from sites on the VPS  (Read 601 times)

0 Members and 1 Guest are viewing this topic.

Offline
***
Hi,


I'm using a VPS on Hetzner, and am trying to force wordpress using SMTP to send emails.
Of course I've created a mail address and it's working fine with non secure connection (port 25). I can even connect to the smtp via SSL from outside the server (tested with 3rd part test sites), but when configuring Wordpress with plugins like WP Mail SMTP I'm getting an error.


I just don't want to reveal my domain, so I've change my hostname to hostname.domain.com and domain to domain.com. I've also hide the full IP.


The problem that I believe I'm facing is that the site is presented as hostname.domain.com.domain.com.domain.com? Why is that happening?


Here's the log:


Quote
Apr  9 19:59:10 cwp postfix/smtpd[5488]: connect from hostname.domain.com.domain.com.domain.com[xxx.69.16.xxx]
Apr  9 19:59:10 cwp postfix/smtpd[5488]: SSL_accept error from hostname.domain.com.domain.com.domain.com[xxx.69.16.xxx]: 0
Apr  9 19:59:10 cwp postfix/smtpd[5488]: warning: TLS library problem: 5488:error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:s3_pkt.c:1493:SSL alert number 48:
Apr  9 19:59:10 cwp postfix/smtpd[5488]: lost connection after CONNECT from hostname.domain.com.domain.com.domain.com[xxx.69.16.xxx]
Apr  9 19:59:10 cwp postfix/smtpd[5488]: disconnect from hostname.domain.com.domain.com.domain.com[xxx.69.16.xxx]

And here's the log when I'm trying to send an email from a 3rd party site to my gmail via the same smtp account:


Quote
Apr  9 20:21:16 cwp postfix/smtpd[9061]: connect from ec2-54-184-121-130.us-west-2.compute.amazonaws.com[54.184.121.130]
Apr  9 20:21:16 cwp postfix/smtpd[9061]: Anonymous TLS connection established from ec2-54-184-121-130.us-west-2.compute.amazonaws.com[54.184.121.130]: TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)
Apr  9 20:21:17 cwp postfix/smtpd[9061]: 68997211CD: client=ec2-54-184-121-130.us-west-2.compute.amazonaws.com[54.184.121.130], sasl_method=PLAIN, sasl_username=wordpress@domain.com
Apr  9 20:21:18 cwp postfix/cleanup[9068]: 68997211CD: message-id=<RNC99NZP77U4.P9KBG3TRCYL33@WIN-AUIR3RRGP88>
Apr  9 20:21:18 cwp postfix/qmgr[700]: 68997211CD: from=<wordpress@domain.com>, size=594, nrcpt=1 (queue active)
Apr  9 20:21:18 cwp postfix/smtpd[9061]: disconnect from ec2-54-184-121-130.us-west-2.compute.amazonaws.com[54.184.121.130]
Apr  9 20:21:18 cwp postfix/smtp[9070]: 68997211CD: to=<myaccount@gmail.com>, relay=gmail-smtp-in.l.google.com[2a00:1450:400c:c0c::1b]:25, delay=1.2, delays=0.63/0.02/0.16/0.35, dsn=2.0.0, status=sent (250 2.0.0 OK  1554830478 q9si21374230wrm.250 - gsmtp)


Would appreciate any help!
« Last Edit: April 09, 2019, 05:24:30 PM by ring_c »

Offline
*
Re: Can't connect to smtp (postfix) via SSL from sites on the VPS
« Reply #1 on: April 09, 2019, 06:31:15 PM »
Try to :

1. Generate your hostname to get SSL working
Quote
CWP.admin > Servers Setting > Change Hostname

2. Then generate MailServer
Quote
CWP.admin > Email > Mail Server Manager

Offline
***
Re: Can't connect to smtp (postfix) via SSL from sites on the VPS
« Reply #2 on: April 09, 2019, 06:44:31 PM »
I've already checked that yesterday and rebuilt the mailserver in any case.
My hostname is set as hostname.domain.com - I think that's the correct way. Correct?

Offline
***
Ok, I've solved this after so long... I'll write down how for those who're facing the same.
First, as a CWP Pro user, I've opened a ticket on the issue. Unfortunately, nothing came out of it (they've sent me to my host, don't ask me why). So... after self learning and investigating, and many fails and errors, here's what saved the issue:


1. I've found accidentally that my /etc/hosts file was totally wrong. Here's how it was:


Code: [Select]
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 hostname.domain.com.domain.com.domain.com.domain.com.domain.com.domain.com hostname.domain.com.domain.com.domain.com.domain.com.domain.com.domain.com
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

# The following lines are desirable for IPv6 capable hosts
::1 hostname.domain.com.domain.com.domain.com.domain.com.domain.com.domain.com hostname.domain.com.domain.com.domain.com.domain.com.domain.com.domain.com
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

127.0.0.1 hostname.domain.com.domain.com.domain.com.domain.com.domain.com.domain.com
127.0.0.1 autoreply.hostname.domain.com.domain.com.domain.com.domain.com.domain.com.domain.com
xxx.69.16.xxx   hostname.domain.com.domain.com.domain.com.domain.com.domain.com


Here's how it is now, fixed:
Code: [Select]
# IPv4
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

# IPv6
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# put your IP address and your hostname and aliases below
xxx.69.16.xxx   hostname.domain.com hostname


Ok. that removed the first 2 lines in my initial error log. But left me with the SSL error:
Code: [Select]
warning: TLS library problem: 5488:error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:s3_pkt.c:1493:SSL alert number 48:


2. After looking for so long all around, I knew something in my configuration is not pointing to the correct CA SSL certification but didn't really know how to fix it with the correct one. Then I found paldig's post here, which saved me.

Edit /etc/postifx/master.cf and replace these:
Code: [Select]
smtpd_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

With this:
Code: [Select]
smtpd_tls_CAfile = /etc/pki/tls/certs/hostname.domain.com.bundle

smtp_tls_CAfile = /etc/pki/tls/certs/hostname.domain.com.bundle

And viola! issue solved!
« Last Edit: April 19, 2019, 05:05:18 AM by ring_c »

Offline
***
Re: Can't connect to smtp (postfix) via SSL from sites on the VPS
« Reply #4 on: April 28, 2019, 12:02:27 PM »
Ok, for some weird reason, this issue popped up again.
Anyone I came back here to read my solution, and have noticed in the last step I've mentioned you should edit master.cf while I meant main.cf. Sorry for that.

Having said that, how can I make sure this won't change again?

Offline
*****
Re: Can't connect to smtp (postfix) via SSL from sites on the VPS
« Reply #5 on: April 29, 2019, 06:12:24 AM »
Check if your postfix/main.cf and dovecot.conf have correct CA-bundle (must have the name like "SSL-name-bundle"
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services