0

I am trying to set up a mail server following the following tutorial: https://www.linode.com/docs/email/postfix/email-with-postfix-dovecot-and-mysql#sph_dovecot

I already set up a mail server using this tutorial before but I have an issue sending mail. I can receive them without any issue.

If I try to send email with telnet telnet 92.243.20.113 25

I got the following log in /var/log/mail.log

Mar 11 17:07:15 server01 postfix/smtpd[10648]: dict_mysql: successful query from host 127.0.0.1
Mar 11 17:07:15 server01 postfix/smtpd[10648]: dict_mysql_lookup: retrieved 0 rows
Mar 11 17:07:15 server01 postfix/smtpd[10648]: maps_find: virtual_alias_maps: @hotmail.com: not found
Mar 11 17:07:15 server01 postfix/smtpd[10648]: mail_addr_find: raphael_bonnaud@hotmail.com -> (not found)
Mar 11 17:07:15 server01 postfix/smtpd[10648]: before input_transp_cleanup: cleanup flags = enable_header_body_filter enable_automatic_bcc enable_address_mapping enable_milters
Mar 11 17:07:15 server01 postfix/smtpd[10648]: after input_transp_cleanup: cleanup flags = enable_header_body_filter enable_automatic_bcc enable_address_mapping
Mar 11 17:07:15 server01 postfix/smtpd[10648]: connect to subsystem public/cleanup
Mar 11 17:07:15 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: queue_id
Mar 11 17:07:15 server01 postfix/smtpd[10648]: input attribute name: queue_id
Mar 11 17:07:15 server01 postfix/smtpd[10648]: input attribute value: 8ACE3260AC
Mar 11 17:07:15 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: (list terminator)
Mar 11 17:07:15 server01 postfix/smtpd[10648]: input attribute name: (end)
Mar 11 17:07:15 server01 postfix/smtpd[10648]: send attr flags = 178
Mar 11 17:07:15 server01 postfix/smtpd[10648]: 8ACE3260AC: client=localhost[127.0.0.1]
Mar 11 17:07:15 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 250 2.1.5 Ok
Mar 11 17:07:53 server01 postfix/smtpd[10648]: < localhost[127.0.0.1]: data
Mar 11 17:07:53 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 354 End data with <CR><LF>.<CR><LF>
Mar 11 17:07:56 server01 postfix/cleanup[10655]: 8ACE3260AC: message-id=<20150311160715.8ACE3260AC@server01.emalsys.eu>
Mar 11 17:07:56 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: status
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute name: status
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute value: 0
Mar 11 17:07:56 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: reason
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute name: reason
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute value: (end)
Mar 11 17:07:56 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: (list terminator)
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute name: (end)
Mar 11 17:07:56 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 250 2.0.0 Ok: queued as 8ACE3260AC
Mar 11 17:07:56 server01 postfix/qmgr[10559]: 8ACE3260AC: from=<alert@test.eu>, size=316, nrcpt=1 (queue active)
Mar 11 17:07:56 server01 postfix/smtp[10657]: 8ACE3260AC: to=<raphael@hotmail.com>, relay=none, delay=55, delays=55/0.01/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=hotmail.com type=MX: Host not found, try again)
Mar 11 17:09:11 server01 postfix/smtpd[10648]: < localhost[127.0.0.1]: quit
Mar 11 17:09:11 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 221 2.0.0 Bye
Mar 11 17:09:11 server01 postfix/smtpd[10648]: match_hostname: localhost ~? 127.0.0.0/8
Mar 11 17:09:11 server01 postfix/smtpd[10648]: match_hostaddr: 127.0.0.1 ~? 127.0.0.0/8
Mar 11 17:09:11 server01 postfix/smtpd[10648]: disconnect from localhost[127.0.0.1]
Mar 11 17:09:11 server01 postfix/smtpd[10648]: master_notify: status 1
Mar 11 17:09:11 server01 postfix/smtpd[10648]: connection closed
Mar 11 17:09:11 server01 postfix/smtpd[10648]: proxymap stream disconnect
Mar 11 17:09:11 server01 postfix/smtpd[10648]: auto_clnt_close: disconnect private/tlsmgr stream
Mar 11 17:09:11 server01 postfix/smtpd[10648]: rewrite stream disconnect
Mar 11 17:09:24 server01 postfix/qmgr[10559]: 7DABD2608F: from=<alert@emalsys.eu>, size=342, nrcpt=1 (queue active)
Mar 11 17:09:24 server01 postfix/qmgr[10559]: 1B74C260A5: from=<raphael@reliefapplications.org>, size=333, nrcpt=1 (queue active)
Mar 11 17:09:24 server01 postfix/smtp[10661]: 1B74C260A5: to=<raphael@blabla.org>, relay=none, delay=461, delays=461/0.01/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=blabla.org type=MX: Host not found, try again)
Mar 11 17:09:27 server01 postfix/smtp[10657]: 7DABD2608F: to=<joanna@blabla.org>, relay=spool.mail.gandi.net[217.70.184.6]:25, delay=4995, delays=4992/0/0.02/3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 78645142298)
Mar 11 17:09:27 server01 postfix/qmgr[10559]: 7DABD2608F: removed
Mar 11 17:10:51 server01 postfix/smtpd[10648]: idle timeout -- exiting

Here my POSTFIX main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/emalsys.eu.crt
smtpd_tls_key_file=/etc/ssl/private/emalsys.eu.key
smtpd_use_tls=yes
smtpd_tls_auth_only = yes

#Enabling SMTP for authenticated users, and handing off authentication to Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = server01.emalsys.eu
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = server01.emalsys.eu, localhost.emalsys.eu, , localhost
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

#Handing off local delivery to Dovecot's LMTP, and telling it where to store mail
virtual_transport = lmtp:unix:private/dovecot-lmtp

#Virtual domains, users, and aliases
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf

I tried to receive email and they arrive normally and create files in /var/mail/vhosts/test.eu/address And time to time some mail are sent (It seems to be random). If I send email using tel net several times, few will go out! If anyone has an idea?

EDIT my DNS zone file:

@ 10800 IN A 92.243.20.113
servertest 10800 IN A 92.243.20.113
www 10800 IN CNAME emalsys.eu.
@ 10800 IN MX 10 emalsys.eu.
@ 10800 IN MX 10 servertest.emalsys.eu.
emalsys.eu 10800 IN MX 20 servertest.emalsys.eu.

EDIT 2: my /etc/resolv.conf

nameserver 2001:4b98:dc0:49::225 
nameserver 217.70.184.225 
nameserver 217.70.184.226 
options timeout:1 attempts:3 rotate

DIG outputs

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> hotmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5163
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 9

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;hotmail.com.           IN  A

;; ANSWER SECTION:
hotmail.com.        1112    IN  A   157.56.172.28
hotmail.com.        1112    IN  A   65.55.77.28
hotmail.com.        1112    IN  A   65.55.85.12
hotmail.com.        1112    IN  A   157.55.152.112

;; AUTHORITY SECTION:
hotmail.com.        65271   IN  NS  ns4.msft.net.
hotmail.com.        65271   IN  NS  ns3.msft.net.
hotmail.com.        65271   IN  NS  ns1.msft.net.
hotmail.com.        65271   IN  NS  ns2.msft.net.

;; ADDITIONAL SECTION:
ns1.msft.net.       257 IN  A   208.84.0.53
ns1.msft.net.       257 IN  AAAA    2620:0:30::53
ns2.msft.net.       65271   IN  A   208.84.2.53
ns2.msft.net.       65271   IN  AAAA    2620:0:32::53
ns3.msft.net.       257 IN  A   193.221.113.53
ns3.msft.net.       257 IN  AAAA    2620:0:34::53
ns4.msft.net.       65271   IN  A   208.76.45.53
ns4.msft.net.       65271   IN  AAAA    2620:0:37::53

;; Query time: 1 msec
;; SERVER: 2001:4b98:dc0:49::225#53(2001:4b98:dc0:49::225)
;; WHEN: Thu Mar 12 18:01:49 CET 2015
;; MSG SIZE  rcvd: 360

root@servertest:/var/mail/vhosts/emalsys.eu/alert/new# nano /etc/resolv.conf
root@servertest:/var/mail/vhosts/emalsys.eu/alert/new# dig hotmail.com

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> hotmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27077
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 9

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;hotmail.com.           IN  A

;; ANSWER SECTION:
hotmail.com.        878 IN  A   65.55.77.28
hotmail.com.        878 IN  A   65.55.85.12
hotmail.com.        878 IN  A   157.55.152.112
hotmail.com.        878 IN  A   157.56.172.28

;; AUTHORITY SECTION:
hotmail.com.        65037   IN  NS  ns3.msft.net.
hotmail.com.        65037   IN  NS  ns2.msft.net.
hotmail.com.        65037   IN  NS  ns1.msft.net.
hotmail.com.        65037   IN  NS  ns4.msft.net.

;; ADDITIONAL SECTION:
ns1.msft.net.       23  IN  A   208.84.0.53
ns1.msft.net.       23  IN  AAAA    2620:0:30::53
ns2.msft.net.       65037   IN  A   208.84.2.53
ns2.msft.net.       65037   IN  AAAA    2620:0:32::53
ns3.msft.net.       23  IN  A   193.221.113.53
ns3.msft.net.       23  IN  AAAA    2620:0:34::53
ns4.msft.net.       65037   IN  A   208.76.45.53
ns4.msft.net.       65037   IN  AAAA    2620:0:37::53

;; Query time: 0 msec
;; SERVER: 2001:4b98:dc0:49::225#53(2001:4b98:dc0:49::225)
;; WHEN: Thu Mar 12 18:05:43 CET 2015
;; MSG SIZE  rcvd: 360

I tried with yahoo and gmail and it is the same look

EDIT iptables rules:

Chain INPUT (policy ACCEPT 26169 packets, 3116K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 27746 packets, 5201K bytes)
 pkts bytes target     prot opt in     out     source               destination         
Chain INPUT (policy ACCEPT 209 packets, 1045K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 123 packets, 9955 bytes)
 pkts bytes target     prot opt in     out     source               destination

EDIT 5: successful mail send

 Mar 12 16:41:51 localhost postfix/smtp[21764]: 603F624A1D: to=<contact@reliefpllications.org>, relay=spool.mail.gandi.net[217.70.184.6]:25, delay=25, delays=22/0/0.01/3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 75F9511648D)
Mar 12 16:41:51 localhost postfix/qmgr[21542]: 603F624A1D: removed

EDIT 6 trying dig with postfix user

admin@servertest:~$ sudo -u postfix dig mx hotmail.com
sudo: unable to resolve host servertest
[sudo] password for admin: 

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> mx hotmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22487
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 73

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;hotmail.com.           IN  MX

;; ANSWER SECTION:
hotmail.com.        2771    IN  MX  5 mx3.hotmail.com.
hotmail.com.        2771    IN  MX  5 mx4.hotmail.com.
hotmail.com.        2771    IN  MX  5 mx1.hotmail.com.
hotmail.com.        2771    IN  MX  5 mx2.hotmail.com.

;; AUTHORITY SECTION:
hotmail.com.        63891   IN  NS  ns1.msft.net.
hotmail.com.        63891   IN  NS  ns4.msft.net.
hotmail.com.        63891   IN  NS  ns3.msft.net.
hotmail.com.        63891   IN  NS  ns2.msft.net.

;; ADDITIONAL SECTION:
mx1.hotmail.com.    2731    IN  A   65.55.92.168
mx1.hotmail.com.    2731    IN  A   65.55.92.184
mx1.hotmail.com.    2731    IN  A   207.46.8.167
[..] I removed lines to make the edit lighter
mx4.hotmail.com.    2737    IN  A   65.54.188.126
mx4.hotmail.com.    2737    IN  A   65.55.33.119
mx4.hotmail.com.    2737    IN  A   65.55.33.135
mx4.hotmail.com.    2737    IN  A   65.55.37.72
mx4.hotmail.com.    2737    IN  A   65.55.37.88
mx4.hotmail.com.    2737    IN  A   65.55.37.104
mx4.hotmail.com.    2737    IN  A   65.55.37.120
ns1.msft.net.       81  IN  A   208.84.0.53
ns1.msft.net.       81  IN  AAAA    2620:0:30::53
ns2.msft.net.       63891   IN  A   208.84.2.53
ns2.msft.net.       63891   IN  AAAA    2620:0:32::53
ns3.msft.net.       81  IN  A   193.221.113.53
ns3.msft.net.       81  IN  AAAA    2620:0:34::53
ns4.msft.net.       63891   IN  A   208.76.45.53
ns4.msft.net.       63891   IN  AAAA    2620:0:37::53

;; Query time: 2 msec
;; SERVER: 2001:4b98:dc0:49::225#53(2001:4b98:dc0:49::225)
;; WHEN: Thu Mar 12 18:24:49 CET 2015
;; MSG SIZE  rcvd: 1400
  • You have posted maillog when delivery failed. Please post the maillog entry when delivery was success. – masegaloeh Mar 11 '15 at 19:29
  • 1
    Given that problem appears to be with getting DNS information for other domains, please try some DNS lookups from the command line. Try dig mx hotmail.com – Paul Haldane Mar 11 '15 at 20:12
  • @PaulHaldane I tried dig but the output seems ok to me. – user269327 Mar 12 '15 at 15:15
  • @masegaloeh I put a successful sent as edit 5 – user269327 Mar 12 '15 at 16:44
2
Host or domain name not found. Name service error for name=hotmail.com

and

Host or domain name not found. Name service error for name=blabla.org

makes it look to me a lot like your DNS isn't working - specifically, name resolution on your mail server isn't working. You will need a working nameserver listed in /etc/resolv.conf, and you will need not to have blocked DNS queries in your firewall, in order for outbound mail to be delivered.

Edit: the iptables rules you quote above are not only useless in isolation (see my comment below for what information we need now), but the INPUT rules are simply wrong; they would need to say --sport 53, not --dport 53, to permit DNS responses. At the moment, I'm very suspicious that you're blocking your own DNS lookups - but we won't know for sure until we see the iptables and ip6tables output that I have requested.

  • It is what I thought but I am experiencing difficulties setting up my DNS I put it in an edit of the question My hostname is server01 my domain is test.eu my IP is 95.142.000.000 Any idea what should be my DNS ? I only have an apache2 server (with SSL) and the mail server I am trying to setup. Any help would be great ! – – user269327 Mar 11 '15 at 16:42
  • 3
    Please read my answer. It doesn't say anything about zonefiles, it makes recommendations for your /etc/resolv.conf. What is in that? It should be whatever DNS server(s) your provider supplied you with. By the way, your IP is 95.142.175.124, and your domain is emalsys.eu; please don't bother obscuring information that you've already put in the question, particularly if you're going to make up random domains. – MadHatter Mar 11 '15 at 17:50
  • 3
    Please cut-and-paste those data into your question, then delete those comments. Without the formatting it's very hard to make sense of them. – MadHatter Mar 11 '15 at 20:25
  • done; I put my comments as edit. What I do not get is I can perfectly receive email but send is random (mostly not working but sometimes a mail is going trough). PS: my port 53 appears as closed when I check it. I am struggling with this one since a while. Your help will be a real relief!! – user269327 Mar 12 '15 at 8:33
  • 2
    OK. It's interesting that one of your listed nameservers has an ipv6 address, but we don't know the state of your v6 firewall (actually, we don't know the state of your v4 firewall, either: rules on their own are meaningless; if you could cut-and-paste the output of iptables -L -n -v; ip6tables -L -n -v that would be helpful. But most helpful of all would be the output of dig mx hotmail.com, and perhaps the same command for a few other domains, as Paul Haldane suggests. – MadHatter Mar 12 '15 at 8:36
0

What are the permissions on /etc/resolv.conf and /etc/nsswitch.conf? They should be readable by all users (postfix isn't running as root).

A quick web search for "postfix resolv.conf permissions" suggests that having one or both of these only readable by root can cause this behaviour.

Despite the permissions on those files being OK (see raphael_b's comment below) I still suspect that this could be the root of the problem since DNS lookups are OK on the command line (I'm assuming that was running as root) but seem to be failing from within postfix.

Could you try running dig as the postfix user?

sudo -u postfix dig mx hotmail.com

If that works then at least we've eliminated file permissions as a problem (and if it doesn't we've got a simpler problem to solve).

  • root@servertest:/etc# ls -l resolv.conf -rw-r--r-- 1 root root 121 Mar 12 12:51 resolv.conf root@servertest:/etc# ls -l /etc/nsswitch.conf -rw-r--r-- 1 root root 475 Feb 20 2014 /etc/nsswitch.conf The files seems to be readable by all users. – user269327 Mar 12 '15 at 17:10
  • OK, I did it; seems fine; but I am surprised by the first line: unable to resolve host servertest Is that normal? – user269327 Mar 12 '15 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy