Espo is not fetching emails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robson
    Junior Member
    • May 2019
    • 19

    Espo is not fetching emails

    Hello,

    My Espo installation on VPS(Ubuntu16) is not fetching any emails.

    1. In Group Email Accounts if I click Test Connection it reports Connection is OK (Gmail account)
    - I can select
    Monitored Folders from my account
    - I can select
    Sent Folder from the list

    So connection with gmail works and both over IMAP and SMTP!!!

    2. I have all options clicked:
    Fetch Emails, Fetch Since...
    3. Server is imap.gmail.com:993 and smtp.gmail.com:587
    4. I can send
    test email using Espo and it works
    5. Ubuntu crontab is set properly and runs
    6. In Espo Adm->Scheduled Jobs->Check Group Email Accounts I get:
    Failed example@gmail.com Today 10:40:03
    7. In /data/logs/espo-2019-07-02.log I have:
    [2019-07-02 08:41:02] Espo.ERROR: CronManager: Failed job running, job [5d1b17363acf4b255]. Error Details: Job CheckInboundEmails 5d0975b6e67319738: [0] cannot connect to host ; error = fsockopen(): unable to connect to ssl://imap.gmail.com:993 (Unknown error) (errno = 0 ) [] []

    Gmail setup cannot be wrong. I have triple checked my configuration and I have all required modules for php 7.1. You can check yourself https://crm.szybkieskladki.pl/phpinfo.php

    What can be the reason? How is it possible that Connection is OK and I can send test emails and any emails from Espo but Espo refuses to fetch emails?????

    I'm stuck with this for a month and cannot use Espo...

    If I run this: openssl s_client -starttls smtp -crlf -connect imap.gmail.com:587 -CApath /etc/ssl/certs/

    I get:
    CONNECTED(00000003)
    depth=2 OU = GlobalSign Root CA - R2, O = GlobalSign, CN = GlobalSign
    verify return:1
    depth=1 C = US, O = Google Trust Services, CN = Google Internet Authority G3
    verify return:1
    depth=0 C = US, ST = California, L = Mountain View, O = Google LLC, CN = smtp.gmail.com
    verify return:1
    ---
    Certificate chain
    0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=smtp.gmail.com
    i:/C=US/O=Google Trust Services/CN=Google Internet Authority G3
    1 s:/C=US/O=Google Trust Services/CN=Google Internet Authority G3
    i:/OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign
    ---
    Server certificate
    -----BEGIN CERTIFICATE-----
    MIIEijCCA3KgAwIBAgIQEtSEkvqmX3f5WfLdZGFYtDANBgkqhk iG9w0BAQsFADBU
    MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVR29vZ2xlIFRydXN0IF NlcnZpY2VzMSUw
    IwYDVQQDExxHb29nbGUgSW50ZXJuZXQgQXV0aG9yaXR5IEczMB 4XDTE5MDYxMTEy
    MjcxMFoXDTE5MDkwMzEyMjAwMFowaDELMAkGA1UEBhMCVVMxEz ARBgNVBAgMCkNh
    bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEzARBg NVBAoMCkdvb2ds
    ZSBMTEMxFzAVBgNVBAMMDnNtdHAuZ21haWwuY29tMIIBIjANBg kqhkiG9w0BAQEF
    AAOCAQ8AMIIBCgKCAQEAsblK/rex7k/k5s6HGrV2XhYVbDc67M6tOel5JYNpbXNw
    1/4/R4xNfL8VfaaKjDSlemdzmHJY2Yv87xI6srRbS0RMUT3HRtVqvb vBLnGKezPC
    LDz3A3SixBTZ0tDgAO1DCLFLfl8EWaP1X+pjl8TKrhZdHjI7wM LX+FRBCH8isk/J
    eHwXFzgnqInG1CHWqIr9Pm3LoULt6Gzxudc2S7oW4GtVlP4H5Z 7xhusRBkvH3CVZ
    XWREL78U/klClaAm2XgvYBh4oVmD5IP+hdWwEkPMQ8iWWzmso5or1+sxHGT JP1sn
    NWHM9pPGxIjxCOVYT7xUA29vbknRpennCwbBCRRM6QIDAQABo4 IBQjCCAT4wEwYD
    VR0lBAwwCgYIKwYBBQUHAwEwGQYDVR0RBBIwEIIOc210cC5nbW FpbC5jb20waAYI
    KwYBBQUHAQEEXDBaMC0GCCsGAQUFBzAChiFodHRwOi8vcGtpLm dvb2cvZ3NyMi9H
    VFNHSUFHMy5jcnQwKQYIKwYBBQUHMAGGHWh0dHA6Ly9vY3NwLn BraS5nb29nL0dU
    U0dJQUczMB0GA1UdDgQWBBQBDg2JaL6UmQko0kTLlK97bIdMDD AMBgNVHRMBAf8E
    AjAAMB8GA1UdIwQYMBaAFHfCuFCaZ3Z2sS3ChtCDoH6mfrpLMC EGA1UdIAQaMBgw
    DAYKKwYBBAHWeQIFAzAIBgZngQwBAgIwMQYDVR0fBCowKDAmoC SgIoYgaHR0cDov
    L2NybC5wa2kuZ29vZy9HVFNHSUFHMy5jcmwwDQYJKoZIhvcNAQ ELBQADggEBAI8B
    7QOKaFlpWmm9xVvnVU5NFpeiGzZ6oKDcOpqEBfQo0r+TDohg1R L+Z8JB9btrxi0m
    OH2ixzynpfqWld4Ru/SKHvZz7N2YtcR+eBe48wZdnh/Jc0H8vA8FBlKh4zp8Y1yM
    l1t4gl2gq99SJWfyt4pBRO754MMb14oKNUrRLED1QOFxGyAesb PeuLmMRsyTqALz
    VIauX/cpHLOjpWtxAdSOl+JZPIMEAhnVwwJU9BYbHsiQe7xiTsy7HaUr 4kVReygk
    gjresjSqLrZUy2VXxiiLi6O/hz9oJEDUeRpswL7vQwj4rBjFGWT0Qk9c97ejVR13
    DovhPHIjhmnMKFdvL80=
    -----END CERTIFICATE-----
    subject=/C=US/ST=California/L=Mountain View/O=Google LLC/CN=smtp.gmail.com
    issuer=/C=US/O=Google Trust Services/CN=Google Internet Authority G3
    ---
    No client certificate CA names sent
    Peer signing digest: SHA256
    Server Temp Key: X25519, 253 bits
    ---
    SSL handshake has read 3035 bytes and written 406 bytes
    Verification: OK
    ---
    New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
    Server public key is 2048 bit
    Secure Renegotiation IS NOT supported
    Compression: NONE
    Expansion: NONE
    No ALPN negotiated
    SSL-Session:
    Protocol : TLSv1.3
    Cipher : TLS_AES_256_GCM_SHA384
    Session-ID:
    Session-ID-ctx:
    Resumption PSK: 00000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1562058191
    Timeout : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no
    Max Early Data: 0

    SSL chains seem to be fine: https://www.sslshopper.com/ssl-check...bkieskladki.pl


    Last edited by robson; 07-02-2019, 09:26 AM.
  • Maximus
    Senior Member
    • Nov 2018
    • 2731

    #2
    Hello.
    Test your connection with this script https://forum.espocrm.com/forum/gene...9685#post49685. Create a PHP file and run it from CLI. If it will fail, this means that there is some restriction on your VPS.

    Comment

    • robson
      Junior Member
      • May 2019
      • 19

      #3
      Hi Max,
      I think ?> is missing in the end of the script... I ran it and I got this:
      PHP Warning: fsockopen(): unable to connect to 1.1.1.1:9998 (Connection timed o ut) in /var/www/crm.szybkieskladki.pl/public_html/test.php on line 6
      (110) Connection timed out

      I agree that this is VPS issue but how to find it? Why Test connection works, Espo sends emails but does not want to Fetch emails? It is not logical. Connection is established on one occasion and is not on the other. Is it the same php method used for test connection/send email and Fetch?

      The same is Campaigns/Mass Emails. If I use Send Test it sends email perfectly but normal campaign for sending emails produces FAILS. Why only test works? There has to be some difference in the code that could explain this behavior.

      I also did the test using:
      Code:
      <?php
      
      $host = "www.google.com";
      $port = "80";
      
      $checkconn = fsockopen($host, $port, $errno, $errstr, 5);
      if (!$checkconn){
      echo "($errno) $errstr";
      } else {
      echo 'ok';
      }
      
      ?>
      And it said "ok" Why it conects to google on port 80 and does not want to connect to cloudflare on 9998? Using 1.1.1.1:80 also produces ok... Why have you proposed port 9998?

      I also used the script to try $host = "imap.gmail.com"; $port = "993"; and got OK.. It is very strange as in your logs it says "cannot connect to host ; error = fsockopen(): unable to connect to ssl://imap.gmail.com:993"


      Last edited by robson; 07-02-2019, 11:26 AM.

      Comment

      • Maximus
        Senior Member
        • Nov 2018
        • 2731

        #4
        You have to set the ip and port parameters of the email server. The parameters 1.1.1.1:9998 it is just an example. You can contact your hosting support service and describe them this issue.

        Comment

        • robson
          Junior Member
          • May 2019
          • 19

          #5
          I used the script to try $host = "imap.gmail.com"; $port = "993"; and got OK.Please note that my Espo log says: "cannot connect to host ; error = fsockopen(): unable to connect to ssl://imap.gmail.com:993"
          How is it possible that your script establishes connection and Espo cannot? It is not hosting issue, it is pure VPS with all ports open. On my server FSOCKOPEN works in CLI but does not work in Espo... How is it possible?
          Last edited by robson; 07-02-2019, 11:49 AM.

          Comment

          • Maximus
            Senior Member
            • Nov 2018
            • 2731

            #6
            I know that EspoCRM works with ssl://imap.gmail.com:993 perfectly. I suppose that the port 993 is blocked on your VPS.

            Comment

            • robson
              Junior Member
              • May 2019
              • 19

              #7
              Max, why do you suggest that VPS is blocked if your script returns OK on "imap.gmail.com"; $port = "993"?

              Comment

              • Maximus
                Senior Member
                • Nov 2018
                • 2731

                #8
                Hi. Sorry for my delayed reply.
                Could you check your CLI PHP version on your VPS? We need to check it, cause when you are making a test connection from the EspoCRM it uses PHP of the web server where your EspoCRM instance is installed, but when the cron runs a job, it uses a CLI PHP.

                Comment

                • robson
                  Junior Member
                  • May 2019
                  • 19

                  #9
                  No problem Max, I'm happy that you are still with me. It is strange but my CLI version is:

                  $ php -v
                  PHP 7.3.6-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:06:26) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.6-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

                  However the Apache says: PHP Version 7.1.30-1+ubuntu16.04.1+deb.sury.org+1

                  Comment

                  • robson
                    Junior Member
                    • May 2019
                    • 19

                    #10
                    I have used sudo update-alternatives --config php to switch CLI to 7.1, now php -v gives:

                    PHP 7.1.30-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:43:14) ( NTS )
                    Copyright (c) 1997-2018 The PHP Group
                    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
                    with Zend OPcache v7.1.30-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

                    Fetching still down (Failed)

                    Comment

                    Working...