Sending mail is ok but not receiving any

Discussion in 'Installation/Configuration' started by Sheshman, Jun 11, 2020.

  1. Sheshman

    Sheshman Member

    Hi,
    Using latest version of ispconfig, everything works except receiving emails, when i send mail from [email protected] to my gmail to another recipient they are receiving my emails, but when i send mail to [email protected] from any recipient it doesn't receive any mail and strangely doesn't return any error.
    my PTR record is ok (i guess), and when i ping mail.fscteknoloji.com it returns from my server with ok.
     

    Attached Files:

  2. nhybgtvfr

    nhybgtvfr Active Member

  3. Sheshman

    Sheshman Member

    just asking to be sure that you didn't missunderstand the problem, i'm having issue with POP why should i check smtp?

    Sending mail without any problem, my problem is not receiving any
     
  4. Sheshman

    Sheshman Member

    netstat -tap output as attached.

    inet_interfaces=all in postfix main.cf
     

    Attached Files:

  5. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    You wrote
    does not work. Check the mail log of your e-mail server, does the mail appear there? If it appear, what happens to the mail if you can not see it.
    What do you mean by that? POP is for reading e-mails, it is not involved when your e-mail server receives e-mails.
    There is link to Tutorial in my signature.
    I checked this:
    Code:
    $ host fscteknoloji.com
    fscteknoloji.com has address 176.236.135.163
    fscteknoloji.com mail is handled by 10 mail.fscteknoloji.com.
    Does that host mail.fscteknoloji.com exist? It does not answer to ping.
     
  6. nhybgtvfr

    nhybgtvfr Active Member

    smtp is for both sending and receiving mail, server - server.
    pop3 / imap is for mail clients retrieving mail from a mailbox on a server.

    you're not getting mail sent to [email protected]?
    that's either your server is receiving mail, but the account can't retrieve it, pop3.
    you server isn't accepting the mail. smtp.
    the remote mail server isn't making a connection to your server. dns / firewall.

    from your initial post, it sounds like an external email account has received mail from you, is trying to reply, but you don't receive the reply, and they don't get any failure message.

    that's either their server can't find your's, or can't connect, which is dns or firewall issues, or smtp misconfiguration their server is probably holding onto the mail and retrying periodically. they'll probably get a message is delayed him around 72 hours after sending.

    or your server is receiving the mail, not rejecting it, but not delivering it to your mailbox.
     
  7. Sheshman

    Sheshman Member

    @Taleman
    i thought SMTP and POP are different things, one for sending one for receiving that's why i said that.
    ping is disabled for that ip but it exist, it's enabled for ping now, you can ping it.
     
  8. Sheshman

    Sheshman Member

    @nhybgtvfr
    oh i thought those are different sorry.
    yes exactly, when i send out from [email protected] to [email protected], gmail receives e-mail, when i reply or send a new mail to [email protected] it's not showing in roundcube.

    let me check /var/log/mail.log and post it here.
     
  9. Sheshman

    Sheshman Member

    Update :
    mail.log file was too big (288mb), i extracted today's logs only, can be downloaded from here https://www.fscteknoloji.com/mail_log_today.zip
    --i was send an test email on 11.06.2020 12:02 it just showed up in Roundcube 5 minutes ago(13:53) but other test mails doesn't show up, is it possible that mail server works fine but somehow it's delaying to receive incoming mails?
    --When i check the mail.log i saw lines like below;
    Code:
    Jun 11 11:39:27 server1 postfix/smtpd[22071]: NOQUEUE: filter: RCPT from mail-lj1-f171.google.com[209.85.208.171]: <[email protected]>: Sender address triggers FILTER amavis:[127.0.0.1]:10026; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-lj1-f171.google.com>
    
    why sender address triggers amavis filter?
     
  10. nhybgtvfr

    nhybgtvfr Active Member

    btw, you may want to check what you have in /etc/mailname, or as the $myhostname in /etc/postfix/main.cf

    your ptr record and dns says it's mail.fscteknoloji.com, but when connecting to it on port 25, your server identifies itself in the banner as server1.fscteknoloji.com. ideally the ptr record and banner should match.

    shouldn't be a big problem, and won't be anything to do with your current issue. but does have potential to cause sent mail to be rejected by some servers.
     
    Sheshman likes this.
  11. Sheshman

    Sheshman Member

    yeah i'm having that problem too, good call, let me talk to the isp to change PTR record as it should be.
     
  12. nhybgtvfr

    nhybgtvfr Active Member

    i'd leave the ptr as it is, just change the contents of /etc/mailname and myhostname in /etc/postfix/main.cf to mail.fscteknoloji.com (
    the myhostname setting, not the $myhostname part in the smtpd_banner line), then restart postfix
     
  13. nhybgtvfr

    nhybgtvfr Active Member

    and the amavis trigger is to get spam/virus scanning done on the mail.
     
  14. Sheshman

    Sheshman Member

    i figure it out something, 2 days ago i was installed FileRun (php script like google drive) to save some files on my server, and FileRun has mail notification system, when i check the mail queue from the admin panel i saw that hundereds of mails in the queue, i check the FileRun settings and noticed that "Notify me when file upload complete", and i was uploaded 7.8GB woth files in it (oh my goodness :) ), so when a file finished upload FileRun sent an notification mail for it, now hundereds of mails in queue and i believe that causing this problem(because 2 or 3 days ago it was working just fine, nothing changed since), i mean mail server is so busy with those mails it can't take a look to other processes.

    Is there a way to kill permenantly all mails in queue? reboot didn't solved the problem.
     
  15. nhybgtvfr

    nhybgtvfr Active Member

    looking at your logs, you may want to check your clamav is working / configured correctly. it's current state will certainly delay mail receipt/delivery.

    if you want to delete mail for specific addresses you can use the script below.
    for the whole queue: https://sharadchhetri.com/2014/02/06/how-to-delete-mail-queue-in-postfix/
    *be very careful on live servers. deleting legitimate customer emails is not good...


    Code:
    #!/usr/bin/perl -w
    # pfdel - deletes message containing specified address from
    # Postfix queue. Matches either sender or recipient address.
    #
    # Usage: pfdel <email_address>
    #
    use strict;
    # Change these paths if necessary.
    my $LISTQ = "/usr/sbin/postqueue -p";
    my $POSTSUPER = "/usr/sbin/postsuper";
    my $email_addr = "";
    my $qid = "";
    my $euid = $>;
    if ( @ARGV !=  1 ) {
            die "Usage: pfdel <email_address>\n";
    } else {
            $email_addr = $ARGV[0];
    }
    if ( $euid != 0 ) {
            die "You must be root to delete queue files.\n";
    }
    
    open(QUEUE, "$LISTQ |") ||
      die "Can't get pipe to $LISTQ: $!\n";
    my $entry = <QUEUE>;    # skip single header line
    $/ = "";                # Rest of queue entries print on
                            # multiple lines.
    while ( $entry = <QUEUE> ) {
            if ( $entry =~ / $email_addr$/m ) {
                    ($qid) = split(/\s+/, $entry, 2);
                    $qid =~ s/[\*\!]//;
                    next unless ($qid);
                    #
                    # Execute postsuper -d with the queue id.
                    # postsuper provides feedback when it deletes
                    # messages. Let its output go through.
                    #
                    if ( system($POSTSUPER, "-d", $qid) != 0 ) {
                            # If postsuper has a problem, bail.
                            die "Error executing $POSTSUPER: error " .
                               "code " .  ($?/256) . "\n";
                    }
            }
    }
    close(QUEUE);
    if (! $qid ) {
            die "No messages with the address <$email_addr> " .
              "found in queue.\n";
    }
    exit 0;
    

    *as an extra caveat, read and understand the script before using it. NEVER run scripts you don't understand... unless you really don't like your server.o_O
     
    Sheshman likes this.
  16. Sheshman

    Sheshman Member

    @nhybgtvfr you know what i owe you a good cold beer :)
    When i run
    Code:
    postsuper -d ALL
    it deleted 190.698 emails from the queue, i'm totally earning the derp avatar of mine.
    yeah you are absolutely right about it, but in this case this is not a commercial server and i am the customer so let's delete it all :)

    Deleting the queue fixed the problem, i did send an test mail from my gmail to fscteknoloji and it arrived under 1 minute, i allready send email to my isp to change ptr record to server1.fscteknoloji.com, only thing scratching my brain is the those lines in mail.log
    Code:
    Jun 11 09:27:44 server1 amavis[28480]: (28480-01-41) (!)connect to /var/run/clamav/clamd.ctl failed, attempt #1: Can't connect to a UNIX socket /var/run/clamav/clamd.ctl: No such file or directory
    Jun 11 09:27:44 server1 amavis[28480]: (28480-01-41) (!)ClamAV-clamd av-scanner FAILED: run_av error: Too many retries to talk to /var/run/clamav/clamd.ctl (All attempts (1) failed connecting to /var/run/clamav/clamd.ctl) at (eval 113) line 659.\n
    Jun 11 09:27:44 server1 amavis[28480]: (28480-01-41) (!)WARN: all primary virus scanners failed, considering backups
    Jun 11 09:27:44 server1 amavis[28480]: (28480-01-41) (!)run_av (ClamAV-clamscan) FAILED - unexpected exit 2, output="LibClamAV Error: cli_loaddbdir(): No supported database files found in /var/lib/clamav\nERROR: Can't open file or directory"
    Jun 11 09:27:44 server1 amavis[28480]: (28480-01-41) (!)ClamAV-clamscan av-scanner FAILED: /usr/bin/clamscan unexpected exit 2, output="LibClamAV Error: cli_loaddbdir(): No supported database files found in /var/lib/clamav\nERROR: Can't open file or directory" at (eval 113) line 950.
    Jun 11 09:27:44 server1 amavis[28480]: (28480-01-41) (!!)AV: ALL VIRUS SCANNERS FAILED
    
    both service clamd status & service clamav status returns "Unit clamav.service could not be found."
     
  17. nhybgtvfr

    nhybgtvfr Active Member

    i'd recommend running through the perfect server tutorial again, redoing any parts relating to amavis or clamav, make sure nothing got accidentally missed, or mistyped.
     
  18. Sheshman

    Sheshman Member

    i think i found the service, it looks like clamav-daemon, when i run service clamav-daemon status it returns;
    Code:
    [email protected]:/home/ispconfig/Desktop# service clamav-daemon status
    ● clamav-daemon.service - Clam AntiVirus userspace daemon
       Loaded: loaded (/lib/systemd/system/clamav-daemon.service; enabled; vendor preset: enabled)
      Drop-In: /etc/systemd/system/clamav-daemon.service.d
               └─extend.conf
       Active: inactive (dead)
    Condition: start condition failed at Thu 2020-06-11 14:03:09 +03; 1h 18min ago
               └─ ConditionPathExistsGlob=/var/lib/clamav/daily.{c[vl]d,inc} was not met
         Docs: man:clamd(8)
               man:clamd.conf(5)
               https://www.clamav.net/documents/
    [email protected]:/home/ispconfig/Desktop#
    
     
  19. nhybgtvfr

    nhybgtvfr Active Member

    like I said, check back through the tutorial, looks like some files are missing, maybe something got missed, or freshclam didn't run properly...
     
  20. Sheshman

    Sheshman Member

    i was allready did that but it didn't solve the problem.

    Problem cause by "freshclam" command returning "ERROR: /var/log/clamav/freshclam.log is locked by another process" during installation, and the tutorial says "The following error can be ignored on the first run of freshclam." the problem is freshclam never runs after you finish the installation because daily.cvd & main.cvd couldn't be downloaded to "/var/lib/clamav" due to "ERROR: /var/log/clamav/freshclam.log is locked by another process" error.

    Fix is :
    Code:
    sudo systemctl stop clamav-freshclam.service
    cd /var/lib/clamav
    wget https://database.clamav.net/daily.cvd
    wget https://database.clamav.net/main.cvd
    service clamav-daemon start
    
    after above commands it runs without any error, and error lines gone in /var/log/mail.log
     

Share This Page