1

I'm trying to build send only mail server using postfix. I folowed this documentation from digital ocean

When I try to send email, it gives below error. (I copied from /var/log/mail.log)

lets say my domain name is domainaddress.com

Feb  9 07:52:54 domainaddress postfix/qmgr[22091]: B22861BA03A: from=<hsntngr@domainaddress>, size=403, nrcpt=1 (queue active)
Feb  9 07:52:54 domainaddress postfix/smtp[26332]: connect to domainaddress[127.0.1.1]:25: Connection refused
Feb  9 07:52:54 domainaddress postfix/smtp[26333]: connect to domainaddress[127.0.1.1]:25: Connection refused
Feb  9 07:52:54 domainaddress postfix/smtp[26332]: 6A8D81BA0FA: to=<hsntngr@domainaddress>, relay=none, delay=29909, delays=29909/0.01/0/0, dsn=4.4.1, status=deferred (conn$
Feb  9 07:52:54 domainaddress postfix/smtp[26332]: connect to domainaddress.com[128.199.50.100]:25: Connection refused
Feb  9 07:52:54 domainaddress postfix/smtp[26333]: 6CDC81BA03F: to=<hsntngr@domainaddress>, relay=none, delay=126295, delays=126295/0.01/0/0, dsn=4.4.1, status=deferred (co$
Feb  9 07:52:54 domainaddress postfix/smtp[26332]: 6BDFF1BA0F8: to=<[email protected]>, relay=none, delay=29997, delays=29997/0.02/0/0, dsn=4.4.1, status=deferred ($
Feb  9 07:52:54 domainaddress postfix/smtp[26333]: connect to domainaddress[127.0.1.1]:25: Connection refused
Feb  9 07:52:54 domainaddress postfix/smtp[26333]: B22861BA03A: to=<your_email_address@domainaddress>, relay=none, delay=126304, delays=126304/0.02/0.01/0, dsn=4.4.1, status..

Even if I setup my host name in config file, host name seems wrong..

Also my config file (/etc/postfix/main.cf)

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.domainaddress.com
mydomain = domainaddress.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $myhostname
mydestination = $myhostname, localhost, $mydomain , www.$mydomain    
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = ipv4

I know I'm doing something wrong at somewhere but I couldn't figure out what it is and where, for two days.

2 Answers 2

4

As Freddy points in a comment, ensure you don’t have unapplied changes by restarting postfix:

service postfix restart

If the issue persists, add a row in /etc/hosts

127.0.0.1 mail.domainaddress.com

Also ensure you can resolve hostnames

nslookup google.com

otherwise, fix it starting from what you have in your network configuration file.

Ensure that your firewall isn’t blocking localhost:25

telent localhost 25

should not return timeout/refused, otherwise

iptables -I INPUT 1 -s 127.0.0.1 -d 127.0.0.1 -p tcp --dport 25 -j ACCEPT
iptables -I OUTPUT 1 -s 127.0.0.1 -d 127.0.0.1 -p tcp --sport 25 -j ACCEPT

Those rules will allow the connection despite anything you might have in your firewall configuration, but that’s just a bad workaround. It might skip any security relying on your firewall logs, for instance.

If the firewall is the case, avoid permanently saving those rules, and start a full review of your iptables ruleset instead.

Reading your logs there is no doubt that postfix is running. Other users coming into this issue might have different/no logs and same symptoms and thus, if they didn’t restart postfix yet, it might be worth for them before editing their iptables ruleset to run also:

service postfix status

and if it’s not running

service postfix start
10
  • I can resolve hostnames but you're right something wrong while resolving localhost:25. I tried to your solution but it throwed Bad argument `—dport' .. Commented Feb 9, 2019 at 9:27
  • It seems my mobile is fixing two - in one — that is a different character. You should input minus minus dport with no spaces.
    – Marco
    Commented Feb 9, 2019 at 9:28
  • thanks, now I'm able to get 220 mail.domainaddress.com ESMTP Postfix (Ubuntu). But still gives connection refused error while sending email. btw something get my attention. it says domainaddress[127.0.1.1]:25: Connection refused.. not domainaddress.com or mail.domainaddress.com just domainaddress. But I filled my hostname properly in /etc/postfix/main.cf is something wrong about this ? Commented Feb 9, 2019 at 9:35
  • 1
    If you just changed your hostname, then restart postfix.
    – Freddy
    Commented Feb 9, 2019 at 9:44
  • 1
    @HasanTıngır by start over, I mean start over troubleshooting this new issue!
    – Marco
    Commented Feb 9, 2019 at 10:03
0

Can it be that port 25 is blocked preventing connections to external smtps (probably by your ISP)? I guess telnet mail.domainaddress.com 25 also fails? Can you try that?

2
  • it says could not resolve mail.domainaddress.com/25: No address associated with hostname. But I created mx record for that ? Commented Feb 9, 2019 at 9:06
  • You can also use the ip address instead of the host name.
    – Freddy
    Commented Feb 9, 2019 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .