Mail configuration to avoid Spam

Discussion in 'Installation/Configuration' started by Magiodev, Jan 3, 2019.

  1. Magiodev

    Magiodev New Member

    Hi to all guys!
    I've built two servers using ISPConfig 3.1 with automated install on both Debian 8 and 9. I'm using "apache2" and "nginx" as well as web services and i have an issue regarding the emails sent from Postfix/Dovecot SMTP server (like from a WordPress contact form).

    The main problem is that when an email is sent by my SMTP server, especially to Gmail, Yahoo and Hotmail, mails are always received inside the spam folder. I would to avoid that without using for example an external SMTP server like smtp.google.com, etc.

    The related servers are:
    • server1.opt-media.es (Debian 8, apache2)
    • server2.opt-media.es (Debian 9, nginx)
    In the second i can't access Roundcube/Squirrelmail but i think this is another problem, related to the SSL certificate as it print an ERR_SSL_PROTOCOL_ERROR on https://server2.opt-media.es:8081/webmail

    I'm noticing something wrong in my mail warn-log file, but i don't know how to fix this authentication error.
    == From my Mail Warn-Log ==

    Jan 3 12:48:42 optserver1-debian8-php5 postfix/smtpd[3520]: warning: unknown[60.171.185.66]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Jan 3 12:50:58 optserver1-debian8-php5 postfix/smtpd[3520]: warning: 59-124-9-251.HINET-IP.hinet.net[59.124.9.251]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Jan 3 12:53:02 optserver1-debian8-php5 postfix/smtpd[3520]: warning: 220-130-140-22.HINET-IP.hinet.net[220.130.140.22]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Jan 3 12:55:16 optserver1-debian8-php5 postfix/smtpd[3818]: warning: unknown[200.111.104.123]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Jan 3 12:57:24 optserver1-debian8-php5 postfix/smtpd[3818]: warning: hostname static-187-44-106-11.optitel.net.br does not resolve to address 187.44.106.11: Name or service not known
    Jan 3 12:57:27 optserver1-debian8-php5 postfix/smtpd[3818]: warning: unknown[187.44.106.11]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Jan 3 12:59:44 optserver1-debian8-php5 postfix/smtpd[3818]: warning: unknown[213.79.118.83]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Jan 3 13:02:04 optserver1-debian8-php5 postfix/smtpd[3818]: warning: hostname 177-103-182-12.dsl.telesp.net.br does not resolve to address 177.103.182.12: Name or service not known​
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I do not trust those automatic ISPConfig installs. I prefer using Perfect Server Guide, then I know what happens and know how the server is set up.
    I think you are piling multiple problems in one post. I'll address only the mail server MX record and reverse name service record.
    Code:
    $ host server1.opt-media.es
    server1.opt-media.es has address 46.101.1.135
    
    $ host opt-media.es
    opt-media.es has address 184.168.131.241
    opt-media.es mail is handled by 0 mail.opt-media.es.
    
    $ host mail.opt-media.es
    mail.opt-media.es has address 160.153.16.63
    
    $ host 160.153.16.63
    63.16.153.160.in-addr.arpa domain name pointer ip-160-153-16-63.ip.secureserver.net.
    
    As you see from the above, mail server (the MX record) for opt-media.es is mail.opt-media.es. However, the PTR record (reverse name service) for its IP-number resolves to ip-160-153-16-63.ip.secureserver.net.
    Most receiving mail servers check the sending IP-number resolves to the hostname the sending e-mail server claims to be.
    You can either name your e-mail server p-160-153-16-63.ip.secureserver.net or fix the PTR record so 160.153.16.63 resolves to mail.opt-media.es.
    There is tutorial on setting up DNS with ISPConfig: https://www.howtoforge.com/tutorial/setting-up-your-own-name-service-with-ispconfig/
     
  3. Magiodev

    Magiodev New Member

    Thanks you Taleman for you quick response! I've perfectly understood the problem and it's caused by we're using and old domain that is still used by godaddy hosting too, i can't change the IP of mail.opt-media.es because i'll break all other website that are hosted on godaddy.

    Do you know if it's possible to force ISPConfig to search on mail1.opt-media.es? as i can split the mail DNS and use one for godaddy and a new one for ISPConfig.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    That's not directly related to ispconfig, its's your server hostname and reverse dns record. Ensure that the server hostname exists in dns and points with a DNS A-Record to the IP address of the server and the reverse DNS record of the server IP must point back to the hostname. The hostname of a server is set in the files /etc/hostname, /etc/hosts, /etc/mailname and /etc/postfix main.cf. Depending on your setup, it might be that /etc/mailname does not exist or that you don't have the hostname in postfix main.cf file, so don't worry when you can't find it in that two places on your system.
     
  5. Magiodev

    Magiodev New Member

    Yes of course is not directly related to ISPConfig, it's not a bug. But i think should be useful for me, and the next ones who will have the same problem :D Thanks for your help!

    So, assuming that i'm managing the domain in Godaddy i think it's correct that i didn't set anything inside DNS zones of ISPConfig. Right?

    If i can't change the IP of mail.opt-media.es cause other website will affected, how can i tell to the server to check mail1.opt-media.es? Inside the files that you told me? I've already created it, but don't know where to put it.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    I just posted this because you asked: "Do you know if it's possible to force ISPConfig to search on mail1.opt-media.es?" and ISPConfig is not involved in that at all, your mail server is postfix and not ISPConfig and ISPConfig is not searching for any domain names.

    That#s correct, if your DNS server is at godaddy then you do not have to add anything in the DNS module on your ISPConfig server.

    Change the server hostname to mail1.opt-media.es in the files I mentioned above if the currently used hostname is in use by another server and then reboot the server.
     
  7. Magiodev

    Magiodev New Member

    In all the files? I use mail1.opt-media.es as MX record on Godaddy only for the Postfix server.

    • /etc/hostname
      optserver1-debian8-php5.6 (i think incorrect)

      don't know why it still contains the initial name of the DigitalOcean's droplet. I've setted server1.opt-media.es during the automated installation of ISPConfig.

    • /etc/hosts
      127.0.1.1 optserver1-debian8-php5.6 optserver1-debian8-php5.6
      127.0.0.1 localhost
      # The following lines are desirable for IPv6 capable hosts
      ::1 ip6-localhost ip6-loopback
      fe00::0 ip6-localnet
      ff00::0 ip6-mcastprefix
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters
      ff02::3 ip6-allhosts


      where i have to include it? why here too is not setted server1.opt-media.es?

    • /etc/mailname
      server1.opt-media.es

      changed with mail1.opt-media.es

    • /etc/postfix/main.cf
      # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
      # information on enabling SSL in the smtp client.
      smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_un$
      myhostname = server1.opt-media.es
      alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
      alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
      myorigin = /etc/mailname
      mydestination = server1.opt-media.es, localhost, localhost.localdomain
      relayhost =
      mynetworks = 127.0.0.0/8 [::1]/128
      mailbox_command = procmail -a "$EXTENSION"
      mailbox_size_limit = 0


      i've copied only a little part of the main.cf file, i've already setted like that:
      myhostname = mail1.opt-media.es
      mydestination = mail1.opt-media.es (i've removed localhost and localhost.localdomain)
    EDIT: I've rebooted and tried to send an email from WordPress with Contact Form 7 to my private @gmail.com and i'm still receiving it inside the spam folder. But if server1.opt-media.es and mail1.opt-media.es are pointing both to the same IP address (cause i don't have a multiserver setting), what's the difference between them?
     
    Last edited: Jan 3, 2019
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Setting up a hostname is e.g. described here in chapter 6: https://www.howtoforge.com/tutorial/debian-minimal-server/2/
    The hostname is normally setup before you even start to install ISPConfig, ISPConfig or the auto installer are not altering the hostname that you have choosen or in your case, that you missed setting upfront.

    You have to set a correct reverse DNS record for your IP as well. This has to be done on the DNS server which holds the records for that IP, this is normally not your own server, contact the support of your data center and ask them to set the reverse dns record.

    Do not remove localhost and localhost.localdomain from main.cf.
     

Share This Page