Postfix not sending/allowing receiving of messages after server (hardware) changed

9,539

WEll this was an odd one but i finally figured it out and fixed it in two steps:

1 - checking the mail.log (i should have started there) i noticed postfix was failling to reach the mysql database. A little research and i figured out that postfix was installed but postfix-mysql wasn't. So i just reinstalled the all mail package using:

sudo apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl phpmyadmin apache2 libapache2-mod-php5 php5 php5-mysql libpam-smbpass

This made it so i finally could sendmail to the outside but not receive it.

2 - after much fidgeting and googling i commented out the smtpd_relay_restrictions line in main.cf, restarteed postfix and voilá, am receiving mail from the outside. a couple of tests showed commenting the line didn't make me an open relay(not sure why) so good enough for me

It's all working now

Share:
9,539

Related videos on Youtube

537mfb
Author by

537mfb

Updated on September 18, 2022

Comments

  • 537mfb
    537mfb almost 2 years

    We had na old notebook runing Ubuntu 12.04 working as a web/ftp/mail server and it worked but since the notebook was a notebook and pretty old and unreliable, a desktop was bought to replace it before it stopped working all together.

    Due to issues with the new desktop's vídeo card, we couldn't use Ubuntu 12.04 so we installed Ubuntu 13.10 and wen't about configuring it.

    Since we removed the notebook from the network, we kept the same Computer Name and local IP address to make things as close to the old server as possible configuration-wise.

    However, something has gone wrong since Postfix is throwing error 451 4.3.0 lookup faillure on every attempt to send a mail, and no email can be received either.

    Our main.cf file is a copy of the one we were using (and working) on the old server (notice we use EHCP)

    # See /usr/share/postfix/main.cf.dist for a commented, more complete version
    
    
    # Debian specific:  Specifying a file name will cause the first
    # line of that file to be used as the name.  The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname
    
    smtpd_banner = $myhostname ESMTP $mail_name powered by Easy Hosting Control Panel (ehcp) on Ubuntu, www.ehcp.net
    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
    myhostname = m21-traducoes.com.pt
    relayhost = 
    mydestination = localhost, 89.152.248.139
    mynetworks = 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/16, 10.0.0.0/8,  89.152.248.0/24
    virtual_alias_domains = 
    virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, proxy:mysql:/etc/postfix/mysql-virtual_email2email.cf
    transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
    virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
    virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
    virtual_mailbox_base = /home/vmail
    virtual_uid_maps = static:5000
    virtual_gid_maps = static:5000
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_security_options = noanonymous
    broken_sasl_auth_clients = yes
    smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,check_client_access hash:/var/lib/pop-before-smtp/hosts,reject_unauth_destination
    smtp_use_tls = yes
    smtpd_use_tls = yes
    smtpd_tls_auth_only = no
    smtpd_tls_CAfile = /etc/postfix/cacert.pem
    smtpd_tls_cert_file = /etc/postfix/smtpd.cert
    smtpd_tls_key_file = /etc/postfix/smtpd.key
    smtpd_tls_loglevel = 1
    smtpd_tls_received_header = yes
    smtpd_tls_session_cache_timeout = 3600s
    tls_random_source = dev:/dev/urandom
    virtual_create_maildirsize = yes
    virtual_mailbox_extended = yes
    virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
    virtual_mailbox_limit_override = yes
    virtual_maildir_limit_message = "The user you are trying to reach is over quota."
    virtual_overquota_bounce = yes
    debug_peer_list = 
    sender_canonical_maps = 
    debug_peer_level = 1
    proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $mynetworks $virtual_mailbox_limit_maps $transport_maps
    
    alias_maps = hash:/etc/aliases
    
    smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,check_client_access hash:/var/lib/pop-before-smtp/hosts,reject_unauth_destination
    smtpd_destination_concurrency_limit = 2
    smtpd_destination_rate_delay = 1s
    smtpd_extra_recipient_limit = 10
    disable_vrfy_command = yes
    smtpd_delay_reject = yes
    smtpd_helo_required = yes
    smtpd_error_sleep_time = 1s
    smtpd_soft_error_limit = 10
    smtpd_hard_error_limit = 20
    

    This configuration was working before but now everytime i try to send a mail in squirrelmail it reports:

    Message not sent. Server replied: 
    Requested action aborted: error in processing
    451 4.3.0 <[email protected]>: Temporary lookup failure
    

    And i can't send mail to it from outsider either. Any ideas?

    EDIT: Here are some issues MXToolBox reports to my domain, answering hopefully to @Teun Vink:

                  BlackList      Mail Server     Web Server    DNS
      Error           4              0               2          0
      Warnings        0              0               0          3
      Passed          0              6               3          12
    

    So the domain is on some blacklist, but that doesn't explain the error at all No mail server issues found (except it's not working) Those two web server errors it's because i don't have HTTPS workin (No SSL Certificate) so the test fails Those 3 DNS warnings we're already there when it was working with the other machine and are related to stuff i can't control:

       SOA Refresh Value is outside of the recommended range
       SOA Expire Value out of recommended range
       SOA NXDOMAIN Value too high
    

    I've searched and as far as i can tell only the guys who sold the retail can change those values and they won't.

    Edit2: I half solved the issue.on the new machine postfix was installed but postfix-mysql waasn't so he couldn't connect to the database (rookie mistake). After fixing that, i can now send mails to the outsider without any issues, however i am still not able to receive mails from utside. The sender doesn't get any message warning about the non-delivery but the message doesn't fall in the inbox and the log shows:

    Nov 13 15:11:57 m21-traducoes postfix/smtpd[5872]: NOQUEUE: reject: RCPT from re
    lay4.ptmail.sapo.pt[212.55.154.24]: 451 4.3.5 <relay4.ptmail.sapo.pt[212.55.154.
    24]>: Client host rejected: Server configuration error; from=<[email protected]>
     to=<[email protected]> proto=SMTP helo=<sapo.pt>
    Nov 13 15:11:57 m21-traducoes postfix/smtpd[5872]: disconnect from relay4.ptmail
    .sapo.pt[212.55.154.24]
    

    Edit3: Removing the smtpd_relay_restrictions parameter from main.cf allows me to receive mail from outsider - but (i think) also makes me an open relay - which is a no-no. Ideas?

    • 537mfb
      537mfb over 10 years
      by sold the retail i mean sold the domain - sorry
    • NickW
      NickW over 10 years
      The error Server configuration error is from your own machine, is the domain that gets rejected your domain, or one you host in virtual_domains?
    • 537mfb
      537mfb over 10 years
      The domains being rejected are any outside of my network. in the exemple was sapo but the same happens with gmail, Hotmail, Yahoo and whatnot - see new edit
    • 537mfb
      537mfb over 10 years
      OK - when i remove the smtpd_relay_restrictions line MXToolBox still says i am not an open relay - was i wrong in that assessment or is MXToolBox wrong? If i am wrong it's fixed by commenting that line - otherwise....
  • NickW
    NickW over 10 years
    Are you sure the resolv.conf is configured correctly for the new machine?
  • 537mfb
    537mfb over 10 years
    resolv.conf is the same as in the old machine (empty apart from the the comment that comes default with it) - which was working on the old machine
  • 537mfb
    537mfb over 10 years
    @NickW - plewase check my question updates