Body: <p>I have a fresh install of civicrm 5.16.3 running on drupal 7. I am having trouble with the mail processor. I've read many pages trying to diagnose the issue and still no luck. </p>
  
  <p>This is what I am getting from civi log, I changed username and server information.</p>
  
  <p>I have tried connecting to a server that I can sucessfully connect to using another computer with civi installed, but no luck on this configuation.</p>
  
  <hr>
  
  <pre><code>Aug 27 12:41:22  [info] $Fatal Error Details = Array
  (
      [message] =&gt; Could not connect to MailStore for username@server &lt;p&gt;Error message: &lt;pre&gt;An error occured while sending or receiving mail. Failed to connect to the server: server:993.&lt;/pre&gt;&lt;p&gt;
      [code] =&gt; 
  )
  
  
  Aug 27 12:41:22  [info] $backTrace = #0 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Error.php(343): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /var/www/html/drupal-7.66/modules/civicrm/CRM/Utils/Mail/EmailProcessor.php(175): CRM_Core_Error::fatal("Could not connect to MailStore for username@server...")
  #2 /var/www/html/drupal-7.66/modules/civicrm/CRM/Utils/Mail/EmailProcessor.php(103): CRM_Utils_Mail_EmailProcessor::_process(FALSE, Object(CRM_Core_DAO_MailSettings), TRUE)
  #3 /var/www/html/drupal-7.66/modules/civicrm/api/v3/Job.php(438): CRM_Utils_Mail_EmailProcessor::processActivities()
  #4 /var/www/html/drupal-7.66/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_job_fetch_activities((Array:1))
  #5 /var/www/html/drupal-7.66/modules/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9))
  #6 /var/www/html/drupal-7.66/modules/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel-&gt;runRequest((Array:9))
  #7 /var/www/html/drupal-7.66/modules/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe("job", "fetch_activities", (Array:1), NULL)
  #8 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/JobManager.php(149): civicrm_api("job", "fetch_activities", (Array:1))
  #9 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/JobManager.php(116): CRM_Core_JobManager-&gt;executeJob(Object(CRM_Core_ScheduledJob))
  #10 /var/www/html/drupal-7.66/modules/civicrm/CRM/Admin/Page/Job.php(173): CRM_Core_JobManager-&gt;executeJobById("3")
  #11 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Page/Basic.php(160): CRM_Admin_Page_Job-&gt;browse(NULL, NULL)
  #12 /var/www/html/drupal-7.66/modules/civicrm/CRM/Admin/Page/Job.php(156): CRM_Core_Page_Basic-&gt;run()
  #13 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Invoke.php(311): CRM_Admin_Page_Job-&gt;run((Array:3), NULL)
  #14 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Invoke.php(85): CRM_Core_Invoke::runItem((Array:16))
  #15 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
  #16 /var/www/html/drupal-7.66/modules/civicrm/drupal/civicrm.module(456): CRM_Core_Invoke::invoke((Array:3))
  #17 /var/www/html/drupal-7.66/includes/menu.inc(527): civicrm_invoke("admin", "job")
  #18 /var/www/html/drupal-7.66/index.php(21): menu_execute_active_handler()
  #19 {main}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:11:13.227Z
Comments.Text: Does that server allow port 993 outbound?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:18:28.333Z
Comments.Text: I just tried to telnet to that port and I connected successfully
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:19:42.680Z
Comments.Text: On the admin screen for the mail account in civi do you have Use SSL checked?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:21:18.423Z
Comments.Text: I do have ssl checked on the mail account
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:26:04.933Z
Comments.Text: I'm out of ideas at the moment since you said you can connect to the same mailserver from another civi install (or was that test a DIFFERENT mail server?)
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:28:47.557Z
Comments.Text: I can connect to the same server using a different civi install, issue seems to be something to do with the civi install and not the mail server
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:32:18.680Z
Comments.Text: So this civi install doesn't seem to connect to any mail server
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:32:46.217Z
Comments.Text: All I can think of is to add debugging output to CRM_Mailing_MailStore_Imap::__construct() and try to see exactly which line it fails on.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:47:24.197Z
Comments.Text: Thanks. I'd like to do that but I'm not sure how. I turned debugging on in the debugging section
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:57:37.593Z
Comments.Text: I just meant edit the file CRM/Mailing/MailStore/Imap.php and add `echo 'this is step X';` or `CRM_Core_Error::debug_log_message('this is step X');` statements sprinkled in __contruct(). Then where it stops outputting your messages is where it fails.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T18:59:46.230Z
Comments.Text: Also you said you tried telnet but it might be useful to also try `openssl s_client -connect server:993` just to check that too.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T19:52:17.760Z
Comments.Text: Looks like the openssl connection works without a problem
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T21:04:30.740Z
Comments.Text: In the message you get does it literally say "server:993" or is that your redacted version?  What mail accounts do you have defined? (at Administer > CiviMail > Mail Accounts)?
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T21:22:02.247Z
Comments.Text: That is my redacted version. It says fails to connect to mail.myserver.org:993 I only have the one account defined right now
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-28T15:49:33.790Z
Comments.Text: So I found where the script fails. In CRM/Mailing/Mailstore.php, I don't get 'this is step X' after the line     $this->_transport = new ezcMailImapTransport($host, NULL, $options);, so I presume the problem is occuring at this point in the code
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-30T16:38:41.587Z
Comments.Text: I tried using an older file of imap_transport.php from civicrm version 4.7.30 where my setup is working, but still no go. I'm wondering if the php version might be the issue
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-30T18:19:18.283Z
Comments.Text: I've gone farther down into the .php, found that vendor/zetacomponents/mail/src/transports/transport_connection.php , $this->connection = @stream_socket_client( "ssl://{$server}:{$port}" there is not an active connection, because if ( is_resource( $this->connection ) ) is skipped and it goes to throw new ezcMailTransportException( "Failed to connect to the server: {$server}:{$port}." );
  not sure how to troubleshoot at this point, any advice would be appreciated
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-30T21:22:51.880Z
Comments.Text: So to add to this, because I suspect that this is an ssl problem, when I do openssl s_client -connect server:993, I do connect, but I get this warning: Verify return code: 20 (unable to get local issuer certificate).
Comments.UserDisplayName: Matt Allard
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-05T14:13:37.163Z
Comments.Text: So I fixed my problem, once I fixed my certificate problem, civimail email to activity started working again. Thanks to the advice on this page, I was able to diagnose the problem more quickly, between the openssl lead and the idea of printing output in php to isolate where the script was failing.
Comments.UserDisplayName: Matt Allard
Tags: <civimail>
Title: Trouble connecting email to activity
ThreadText: # Trouble connecting email to activity
  
  (Asked by: username_0 on 2019-08-27)
  
  I have a fresh install of civicrm 5.16.3 running on drupal 7. I am having trouble with the mail processor. I've read many pages trying to diagnose the issue and still no luck.
  
  This is what I am getting from civi log, I changed username and server information.
  
  I have tried connecting to a server that I can sucessfully connect to using another computer with civi installed, but no luck on this configuation.
  
  ---
  
  ```
  Aug 27 12:41:22  [info] $Fatal Error Details = Array
  (
      [message] => Could not connect to MailStore for username@server <p>Error message: <pre>An error occured while sending or receiving mail. Failed to connect to the server: server:993.</pre><p>
      [code] => 
  )
  
  Aug 27 12:41:22  [info] $backTrace = #0 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Error.php(343): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /var/www/html/drupal-7.66/modules/civicrm/CRM/Utils/Mail/EmailProcessor.php(175): CRM_Core_Error::fatal("Could not connect to MailStore for username@server...")
  #2 /var/www/html/drupal-7.66/modules/civicrm/CRM/Utils/Mail/EmailProcessor.php(103): CRM_Utils_Mail_EmailProcessor::_process(FALSE, Object(CRM_Core_DAO_MailSettings), TRUE)
  #3 /var/www/html/drupal-7.66/modules/civicrm/api/v3/Job.php(438): CRM_Utils_Mail_EmailProcessor::processActivities()
  #4 /var/www/html/drupal-7.66/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_job_fetch_activities((Array:1))
  #5 /var/www/html/drupal-7.66/modules/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
  #6 /var/www/html/drupal-7.66/modules/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel->runRequest((Array:9))
  #7 /var/www/html/drupal-7.66/modules/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("job", "fetch_activities", (Array:1), NULL)
  #8 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/JobManager.php(149): civicrm_api("job", "fetch_activities", (Array:1))
  #9 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/JobManager.php(116): CRM_Core_JobManager->executeJob(Object(CRM_Core_ScheduledJob))
  #10 /var/www/html/drupal-7.66/modules/civicrm/CRM/Admin/Page/Job.php(173): CRM_Core_JobManager->executeJobById("3")
  #11 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Page/Basic.php(160): CRM_Admin_Page_Job->browse(NULL, NULL)
  #12 /var/www/html/drupal-7.66/modules/civicrm/CRM/Admin/Page/Job.php(156): CRM_Core_Page_Basic->run()
  #13 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Invoke.php(311): CRM_Admin_Page_Job->run((Array:3), NULL)
  #14 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Invoke.php(85): CRM_Core_Invoke::runItem((Array:16))
  #15 /var/www/html/drupal-7.66/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
  #16 /var/www/html/drupal-7.66/modules/civicrm/drupal/civicrm.module(456): CRM_Core_Invoke::invoke((Array:3))
  #17 /var/www/html/drupal-7.66/includes/menu.inc(527): civicrm_invoke("admin", "job")
  #18 /var/www/html/drupal-7.66/index.php(21): menu_execute_active_handler()
  #19 {main}
  
  ```
  
  **Tags:** civimail
  
  > **Comments:**
  > **username_1**: Does that server allow port 993 outbound?  
  > **username_0**: I just tried to telnet to that port and I connected successfully  
  > **username_1**: On the admin screen for the mail account in civi do you have Use SSL checked?  
  > **username_0**: I do have ssl checked on the mail account  
  > **username_1**: I'm out of ideas at the moment since you said you can connect to the same mailserver from another civi install (or was that test a DIFFERENT mail server?)  
  > **username_0**: I can connect to the same server using a different civi install, issue seems to be something to do with the civi install and not the mail server  
  > **username_0**: So this civi install doesn't seem to connect to any mail server  
  > **username_1**: All I can think of is to add debugging output to CRM_Mailing_MailStore_Imap::__construct() and try to see exactly which line it fails on.  
  > **username_0**: Thanks. I'd like to do that but I'm not sure how. I turned debugging on in the debugging section  
  > **username_1**: I just meant edit the file CRM/Mailing/MailStore/Imap.php and add `echo 'this is step X';` or `CRM_Core_Error::debug_log_message('this is step X');` statements sprinkled in __contruct(). Then where it stops outputting your messages is where it fails.  
  > **username_1**: Also you said you tried telnet but it might be useful to also try `openssl s_client -connect server:993` just to check that too.  
  > **username_0**: Looks like the openssl connection works without a problem  
  > **username_2**: In the message you get does it literally say "server:993" or is that your redacted version?  What mail accounts do you have defined? (at Administer > CiviMail > Mail Accounts)?  
  > **username_0**: That is my redacted version. It says fails to connect to mail.myserver.org:993 I only have the one account defined right now  
  > **username_0**: So I found where the script fails. In CRM/Mailing/Mailstore.php, I don't get 'this is step X' after the line     $this->_transport = new ezcMailImapTransport($host, NULL, $options);, so I presume the problem is occuring at this point in the code  
  > **username_0**: I tried using an older file of imap_transport.php from civicrm version 4.7.30 where my setup is working, but still no go. I'm wondering if the php version might be the issue  
  > **username_0**: I've gone farther down into the .php, found that vendor/zetacomponents/mail/src/transports/transport_connection.php , $this->connection = @stream_socket_client( "ssl://{$server}:{$port}" there is not an active connection, because if ( is_resource( $this->connection ) ) is skipped and it goes to throw new ezcMailTransportException( "Failed to connect to the server: {$server}:{$port}." ); not sure how to troubleshoot at this point, any advice would be appreciated  
  > **username_0**: So to add to this, because I suspect that this is an ssl problem, when I do openssl s_client -connect server:993, I do connect, but I get this warning: Verify return code: 20 (unable to get local issuer certificate).  
  > **username_0**: So I fixed my problem, once I fixed my certificate problem, civimail email to activity started working again. Thanks to the advice on this page, I was able to diagnose the problem more quickly, between the openssl lead and the idea of printing output in php to isolate where the script was failing.  
  
  ---
  
  ## 0 answers
  
  