wader / postfix-relay

Postfix SMTP relay docker image
https://hub.docker.com/r/mwader/postfix-relay/
MIT License
118 stars 41 forks source link

Not getting the whole FQDN thing #6

Closed falconmick closed 5 years ago

falconmick commented 5 years ago

Hi Sorry for more of a Mail question in general than the one to this repo.

When I get to the part for the docker-compose.yml of:

  environment:
    - POSTFIX_myhostname=smtp.domain.tld
    - OPENDKIM_DOMAINS=smtp.domain.tld

I have no idea what myhostname should be nor any extra DNS setup I will need to do.

Basically I have a Wordpress services running in docker and the mail is becoming a big pain due to sendmail not being the most strait forward thing ever.

If I have the domain: awesomesite.com and I want to send emails from it, what would those settings end up being? do I need to prepend smtp. to awesomesite.com and create an A record??

My site already has a Google inbox so I can't mess with the mx records.

Cheers, Michael.

falconmick commented 5 years ago

Oh also not to clog up your issues inbox any more:

When I connect my Wordpress emailing functionality what settings do I use.

I opened the Dockerfile and saw 25 is exposed, so I assume I would connect to port 25, but how would I set the SMTP server address given I won't be exposing that port publicly? Is it just setup so that when I email smtp.awesomesite.com that the DNS setting I assume I made resolves to my box's IP, and then docker somhow knows that it can resolve it via the private docker network that isn't exposed? Or do I need to inject a hosts record with the IP of the relay box pointed at by smtp.awesomesite.com?

Cheers again!

wader commented 5 years ago

Hi!, for myhostname i don't think it is that important. But maybe good that it resolves to the source IP which will be used when connecting to other SMTP server when sending mail. What might be more important now a days is to setup SPF records for your domain.

For how to connect to the SMTP relay i would strongly suggest you use docker networks somehow. Simples is probably to use one docker-compose config that has both a wordpress and postfix-relay service as then docker-compose will create a "default" network between them so they can communicate. Then wordpress should be able to reach the SMTP relay using normal DNS. For example if you have "smtp" service then wordpress should be able to use "smtp" as hostname for it's SMTP server. See https://github.com/wader/postfix-relay#using-docker-compose

falconmick commented 5 years ago

Ok I've managed to get it going, now its just tinkerin with all the nobs to get out of that spam box!

This is the big issue I have currently (source: https://www.mail-tester.com/test-qhuyo):

We check if there is a server (A Record) behind your hostname hostname.
You may want to publish a DNS record (A type) for the hostname hostname or use a different hostname in your mail software.

you can also see the raw email:

Received: by mail-tester.com (Postfix, from userid 500)
    id 3AE9CA04BF; Thu, 29 Nov 2018 10:14:45 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail-tester.com
X-Spam-Level: ***
X-Spam-Status: No/3.0/5.0
X-Spam-Test-Scores: FSL_HELO_NON_FQDN_1=0.001,HTML_MESSAGE=0.001,
    HTML_MIME_NO_HTML_TAG=0.635,MIME_HTML_ONLY=1.105,
    RCVD_IN_SORBS_DUL=0.001,RDNS_NONE=1.274,SPF_PASS=-0.001,
    URIBL_BLOCKED=0.001
X-Spam-Last-External-IP: 123.456.789.01
X-Spam-Last-External-HELO: hostname
X-Spam-Last-External-rDNS: 
X-Spam-Date-of-Scan: Thu, 29 Nov 2018 10:14:45 +0100
X-Spam-Report: 
    *  0.0 FSL_HELO_NON_FQDN_1 No description available.
    *  0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was
    *      blocked.  See
    *      http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
    *      for more information.
    *      [URIs: sendingemailfromhere.com.au]
    *  0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP
    *      address
    *      [123.456.789.01 listed in dnsbl.sorbs.net]
    * -0.0 SPF_PASS SPF: sender matches SPF record
    *  1.1 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
    *  0.0 HTML_MESSAGE BODY: HTML included in message
    *  0.6 HTML_MIME_NO_HTML_TAG HTML-only message, but there is no HTML
    *      tag
    *  1.3 RDNS_NONE Delivered to internal network by a host with no rDNS
Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=123.456.789.01; helo=hostname; envelope-from=contact@sendingemailfromhere.com.au; receiver=test-autkx@mail-tester.com 
DMARC-Filter: OpenDMARC Filter v1.3.1 mail-tester.com 81C199FE8B
Authentication-Results: mail-tester.com; dmarc=none header.from=sendingemailfromhere.com.au
Received: from hostname (unknown [123.456.789.01])
    (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))
    (No client certificate requested)
    by mail-tester.com (Postfix) with ESMTPS id 81C199FE8B
    for <test-autkx@mail-tester.com>; Thu, 29 Nov 2018 10:14:43 +0100 (CET)
Received: from wp.sendingemailfromhere.com.au (projectname-wordpress.projectname_default [172.21.0.5])
    by hostname (Postfix) with ESMTP id 548CA23C585
    for <test-autkx@mail-tester.com>; Thu, 29 Nov 2018 09:14:41 +0000 (UTC)
Date: Thu, 29 Nov 2018 09:14:41 +0000
To: test-autkx@mail-tester.com
From: WordPress <contact@sendingemailfromhere.com.au>
Subject: Test email from https://wp.sendingemailfromhere.com.au
Message-ID: <b2249fc49f2094c2e4dfee34a20f047e@wp.sendingemailfromhere.com.au>
X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
MIME-Version: 1.0
Content-Type: text/html; charset=iso-8859-1

This test email proves that your WordPress installation at https://wp.sendingemailfromhere.com.au can send emails.\n\nSent: Thu, 29 Nov 2018 09:14:41 +0000

it looks like my helo is sending hostname not sendingemailfromhere.com.au

Here is my docker-compose config

  smtp:
    image: mwader/postfix-relay
    restart: always
    container_name: projectname-smtp
    environment:
      - POSTFIX_sendingemailfromhere.com.au=smtp.sendingemailfromhere.com.au
    expose:
      - "25"

Any idea on how to make the helo send sendingemailfromhere.com.au or smtp.sendingemailfromhere.com.au, which ever it's supposed to?

wader commented 5 years ago

I think POSTFIX_myhostname=smtp.sendingemailfromhere.com.au should solve that. I'm quite sure it is what postfix will use at HELO.

You can probably skip expose 25 as it's already define by the Dockefile and i think expose is only needed if you use links (which you probably don't need if you use DNS instead)

falconmick commented 5 years ago

@wader The confusion I am experiencing is that the HELO is sending hostname as it's host name not sendingemailfromhere.com.au OR smtp.sendingemailfromhere.com.au

I'm not even 100% sure what it should be.

I will do some digging into postfix and how HELO works, if I find more info I will get back to you, or if you figure something out let me know.

wader commented 5 years ago

I just noticed POSTFIX_sendingemailfromhere.com.au=smtp.sendingemailfromhere.com.au in your example. Just to be clear, postfix has a config option named ”myhostname” so you should not expand it as a variable etc.

falconmick commented 5 years ago

Yeah I litterally just figured that out!

On Fri, 30 Nov 2018 at 10:38 AM, Mattias Wadman notifications@github.com wrote:

I just noticed POSTFIX_sendingemailfromhere.com.au= smtp.sendingemailfromhere.com.au in your example. Just to be clear, postfix has a config option named ”myhostname” so you should not expand it as a variable etc.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wader/postfix-relay/issues/6#issuecomment-443070449, or mute the thread https://github.com/notifications/unsubscribe-auth/AAri6fJUj6ulwFgVnAas2pfs-hD3zNomks5u0JotgaJpZM4Y24EK .

wader commented 5 years ago

Aha good 👍 yeah that option is named a bit weirdly. So hostname works now?

falconmick commented 5 years ago

Yeah sure does

On Fri, 30 Nov 2018 at 4:11 PM, Mattias Wadman notifications@github.com wrote:

Aha good 👍 yeah that option is named a bit weirdly. So hostname works now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wader/postfix-relay/issues/6#issuecomment-443124889, or mute the thread https://github.com/notifications/unsubscribe-auth/AAri6WqOg9lCo8XuahKaA15iLyB8_cYWks5u0OgtgaJpZM4Y24EK .

wader commented 5 years ago

Can close?

I did a change to make this more clear https://github.com/wader/postfix-relay/commit/840a28d539cd200b23887e24cac06d2e707e2406 Thanks for bringing this up!

falconmick commented 5 years ago

Cheers no problem you can close, thanks for the clarification

On Fri, 30 Nov 2018 at 8:34 PM, Mattias Wadman notifications@github.com wrote:

Can close?

I did a change to make this more clear 840a28d https://github.com/wader/postfix-relay/commit/840a28d539cd200b23887e24cac06d2e707e2406 Thanks for bringing this up!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wader/postfix-relay/issues/6#issuecomment-443190603, or mute the thread https://github.com/notifications/unsubscribe-auth/AAri6bW5Vx-Vpr_qtYVe6VfeAYu3nu9cks5u0SW3gaJpZM4Y24EK .