0

I want to configure localhost to send emails via postfix server, I do this for testing my solution of setup Docker with Wordpress (with solution found on internet email was not working, also curl but that was because of corporate CA SSL certs). Right now I'm testing this on Fedora and try to send to my two account at onet.pl and jcubic.pl domains they both rejected my emails.

Here are the postfix logs:

Apr  4 13:24:14 23c96150d42f postfix/smtp[134]: BCAA01659A0: to=<blog@jcubic.pl>, relay=mail.jcubic.pl[185.255.40.21]:25, delay=0.25, delays=0/0/0.07/0.17, dsn=5.7.1, status=bounced (host mail.jcubic.pl[185.255.40.21] said: 550 5.7.1 <blog@jcubic.pl>: Recipient address rejected: Please see http://www.openspf.net/Why?s=helo;id=jcubic.pl;ip=185.129.113.210;r=unknown (in reply to RCPT TO command))
Apr  4 13:24:14 23c96150d42f postfix/qmgr[95]: BCAA01659A0: removed
Apr  4 13:25:41 23c96150d42f postfix/smtp[134]: 2D02E1659A0: to=<jcubic@onet.pl>, relay=mx.poczta.onet.pl[213.180.147.146]:25, delay=0.85, delays=0/0/0.85/0, dsn=4.7.1, status=deferred (host mx.poczta.onet.pl[213.180.147.146] refused to talk to me: 220-mx.poczta.onet.pl ESMTP 450 4.7.1 Client host rejected: cannot find your reverse hostname, [185.129.113.210])

First is SPF protection, I can ignore that and only deal with onet.pl that show error about reverse hostname, I've read that I need to have proper DNS records at jcubic.pl. I can setup DNS on jcubic.pl, this just for now to see if email works, but I don't know how to and multiple A DNS records. I'm also not sure exactly how I can do that (how record should look like).

I was testing my docker-wordpress combo at work with Ubuntu on OpenStack and I was able to send email to gmail corporate account.

I'm using this setup, I have postfix instance as docker compose service with this config:

  postfix:
    image: catatnight/postfix
    environment:
      maildomain: example.com # at work here was valid domain of my company (gene.com)
      smtp_user: postfix:postfixpass
    ports:
      - "25:25"
    restart: always

port 25 probably will not be public it's just for testing, I wasn't sure if that was the problem of no sending emails:

and my wordpress image use msmtp command to send emails, I'm testing right now this:

echo "Hello this is sending email using msmtp" | msmtp <name>@onet.pl
echo "Hello this is sending email using msmtp" | msmtp <name>@jcubic.pl

My msmtp config look like this:

# Set defaults.
defaults
# Enable or disable TLS/SSL encryption.
tls off
tls_starttls off
# Setup WP account's settings.
account postfix
host postfix
port 25
auth login
user postfix@jcubic.pl
password postfixpass
from blog@jcubic.pl

logfile /var/log/msmtp/msmtp.log

account default: postfix

I'm testing different user nad from, can I just configure DNS on jcubic.pl to verify that my local IP (that's dynamic) is valid just for now, so I can test if send email works? My domain jcubic.pl is on shared hosting, but I can add DNS records. Is possible to also fix SPF issue. How this will work on normal server. At work I use domain of my company but it was intranet IP address (instance of private OpenStack), I'm not sure why gmail thought that sender was valid.

I also have another question is postfix mail server need to be public and access on IP that sent the email? this is how it was working at work (there was public port from docker postfix container), but here I have localhost and also NAT router, my public IP is different and mail server is not accessed from internet. I'm not sure what DNS records my company have.

jcubic
  • 230
  • 1
  • 4
  • 14

1 Answers1

1

Can I just configure DNS on jcubic.pl to verify that my local IP (that's dynamic) is valid?

Sending email directly from a dynamic IP might be problematic. You should probably be using your ISPs SMTP servers or through your own email server using submission. Not to mention the IP address is currently on several DNS based blac klists (DNSBL).

Recipient address rejected: Please see
http://www.openspf.net/Why?s=helo;id=jcubic.pl;ip=185.129.113.210;r=unknown

The 185.129.113.210 is not allowed to send email for jcubic.pl per

jcubic.pl. IN TXT "v=spf1 a mx include:_spf.atthost.pl -all"

You would have to add +ip4:185.129.113.210 possibly whole +íp4:185.129.112.0/22 due to the dynamic IP address. That's not wise, at if would allow every device on PL-UNINET-OWN-INFRASTRUCTURE network block to send email as jcubic.pl. Using authenticated SMTP on submission port is a solution for that. The local Postfix could send all non-local mail through your existing mail server as a relayhost.

450 4.7.1 Client host rejected: cannot find your reverse hostname, [185.129.113.210]

This is something you can't simply fix by modifying your forward zone for jcubic.pl, as this is about the missing reverse PTR record for IP address 185.129.113.210. Only the owner of the IP block can change those records. dig -x 185.129.113.210 returns NXDOMAIN for 210.113.129.185.in-addr.arpa. IN PTR, so currently there's no reverse record at all.

Many receiving SMTP servers require that there's both matching forward and reverse records and that they match the SMTP banner (how the server introduces itself on HELO commands) too.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122