sending mail rejected due to TLS verification

39 Views Asked by At

For testing my app, I need to send a mail over my companies mailhost.

Unfortunately I have to use a tunnel to connect to that host and so sending mail is rejected because:

tls: failed to verify certificate: x509: certificate is valid for *.example.com, example.com, not host.docker.internal

Is there any way around this? Can I disable TLS?

I'm using github.com/jhillyerd/enmime

Update after 2 comments

  1. I do not want to switch of TLS on the mailhost. I simply want to tell my net/smtp's Sendmail or enmime's Send to not do TLS verification. I already achieved that by copying Sendmail's code, leaving out the TLS-Part. But I don't like that approach as it feels very "hacky".
  2. I'm working in a VPN and there are no credentials required when sending mails, as the mailhost can only be reached by a small set of known hosts.
  3. This is also why I need a tunnel through a jumphost in order to reach the mailhost from my developer machine:

Dockercontainer --> DevMac ---> Jumphost ---> Mailhost

So I do a

ssh -L9925:mailhost.example.com:25 [email protected]

That's why I have defined the mailhost to be "host.docker.internal:9925".

Maybe there is another idea how I can reach the mailhost by its real name?

Update after finding a workaround

I now simply add on my developer container an entry to /etc/hosts pointing my real mailhost.example.com to the IP of host.docker.internal .

That way TLS verification succeeds.

0

There are 0 best solutions below