CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Windows and IIS installations »
  • Error with Outbound Mail Settings.
Pages: [1]

Author Topic: Error with Outbound Mail Settings.  (Read 5891 times)

mcarson

  • I post occasionally
  • **
  • Posts: 110
  • Karma: 5
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.4.22
Error with Outbound Mail Settings.
May 09, 2010, 03:43:44 am
Successfully managed to install CiviCRM on Drupal with PHP and MySQL on a test VM and got it running on a private network.

As a test (and a learning process) I was configuring all the required settings through the modules, and encountered the following errors at the top of the page at "http://192.168.1.4/drupal/index.php?q=civicrm/admin/setting/smtp&reset=1" :

warning: mcrypt_create_iv() [function.mcrypt-create-iv]: Cannot open source device in C:\Inetpub\wwwroot\drupal\sites\all\modules\civiCRM\CRM\Utils\Crypt.php on line 69.
warning: mcrypt_generic_init() [function.mcrypt-generic-init]: Iv size incorrect; supplied length: 0, needed: 32 in C:\Inetpub\wwwroot\drupal\sites\all\modules\civiCRM\CRM\Utils\Crypt.php on line 73.

I have done the usual research before posting and discovered: http://forum.civicrm.org/index.php/topic,12761.msg55528.html#msg55528. Seems to be the same issue. I have searched the Issue Tracker for the aforementioned issue (CRM-5998) and cannot find an issue nor any updates.

1) What are the consequences of these errors - do they prevent the email configurations from working?
2) Are the modifications that http://forum.civicrm.org/index.php?action=profile;u=10749 detailed on the post 'okay' to make?

Thanks in advance.

“Anyone who has never made a mistake has never tried anything new.” - Albert Einstein
"If you are travelling at the speed of light and you turn on your headlights, would they work?" - Unknown

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Error with Outbound Mail Settings.
May 09, 2010, 08:27:33 am

none of us run windows and hence it a bit hard for us to debug and/or fix this error. Please do check and see if the fix works for your install

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mcarson

  • I post occasionally
  • **
  • Posts: 110
  • Karma: 5
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.4.22
Re: Error with Outbound Mail Settings.
May 13, 2010, 02:05:19 am
To update this post with the results of my test:

Changed the php.ini file for:
Code: [Select]
error_reporting=E_ALL
display_errors= on

Made a backup of \drupal\sites\all\modules\civicrm\CRM\utils\Crypt.php and modified original to contain the following:

Code: [Select]
<?php

/*
 +--------------------------------------------------------------------+
 | CiviCRM version 3.1                                                |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2010                                |
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 | CiviCRM is free software; you can copy, modify, and distribute it  |
 | under the terms of the GNU Affero General Public License           |
 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
 |                                                                    |
 | CiviCRM is distributed in the hope that it will be useful, but     |
 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
 | See the GNU Affero General Public License for more details.        |
 |                                                                    |
 | You should have received a copy of the GNU Affero General Public   |
 | License and the CiviCRM Licensing Exception along                  |
 | with this program; if not, contact CiviCRM LLC                     |
 | at info[AT]civicrm[DOT]org. If you have questions about the        |
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
*/

/**
 *
 * @package CRM
 * @copyright CiviCRM LLC (c) 2004-2010
 * $Id$
 *
 */
 
 /**
  * Modified by Mark Carson 10 May 2010 to cope with the lack of functionality in PHP 5.2*
  * PHP 5.3 allows support on Windows for mcrypt_create_iv() however PHP 5.3 is NOT supported
  * by CiviCRM.
  * Created a function that emulates mcrypt_create_iv but does not require PHP5.3 code
  * Modified encrypt and decrypt to use the emulated function (untested) (10/05/2010)
  * -----
  * 12/05/2010 Discovered that custom function prevents Outbound Mail Settings page from 
  * displaying:
  * display_errors=on
  * Fatal error: Call to undefined function alt_mcrypt_create_iv() in
  * C:\Inetpub\wwwroot\drupal\sites\all\modules\civicrm\CRM\Utils\Crypt.php on line 85
  * -----
  * (Inadequate knowledge of PHP coding) Got it working by changing encrypt and decrypt to 
  * have an alternative random generator.
  */
  

class CRM_Utils_Crypt {

    static function 
encrypt( $string ) {
        if ( empty( 
$string ) ) {
            return 
$string;
        }

        if ( 
function_exists( 'mcrypt_module_open' ) &&
             
defined( 'CIVICRM_SITE_KEY' ) ) {
            
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_ECB, '');
$iv = '';
$size = 32;
for ($i = 0; $i < $size; $i++) {
$iv .= chr(rand(0,255));
}
            
/* $iv = alt_mcrypt_create_iv( 32 ); */
            
$ks = mcrypt_enc_get_key_size($td);
            
$key = substr( sha1( CIVICRM_SITE_KEY ), 0, $ks );
            
            
mcrypt_generic_init($td, $key, $iv);
            
$string = mcrypt_generic($td, $string );
            
mcrypt_generic_deinit($td);
            
mcrypt_module_close($td);
        }
        return 
base64_encode( $string );
    }

    static function 
decrypt( $string ) {
        if ( empty( 
$string ) ) {
            return 
$string;
        }

        
$string = base64_decode( $string );

        if ( 
function_exists( 'mcrypt_module_open' ) &&
             
defined( 'CIVICRM_SITE_KEY' ) ) {
            
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_ECB, '');
$iv = '';
$size = 32;
for ($i = 0; $i < $size; $i++) {
$iv .= chr(rand(0,255));
}
            
/* $iv = alt_mcrypt_create_iv( 32 );*/
            
$ks = mcrypt_enc_get_key_size($td);
            
$key = substr( sha1( CIVICRM_SITE_KEY ), 0, $ks );
            
            
mcrypt_generic_init($td, $key, $iv);
            
$string = rtrim( mdecrypt_generic($td, $string ) );
            
mcrypt_generic_deinit($td);
            
mcrypt_module_close($td);
        }
        
        return 
$string;
    }
}

Restarted IIS 5.1 using command prompt:
Code: [Select]
net stop iisadmin
...
net start w3svc

Re-entered the Outbound Mail Settings page and made the required settings for my external 1and1 provided SMTP server and successfully tested email.

The question now: Will all the email functionality work?  :-\

I will update this post in due course.
“Anyone who has never made a mistake has never tried anything new.” - Albert Einstein
"If you are travelling at the speed of light and you turn on your headlights, would they work?" - Unknown

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Error with Outbound Mail Settings.
May 13, 2010, 09:31:53 am
If the test email worked, the other mails will as well, unless your smtp provider limits the number of emails you can send (gmail does for instance).

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

mcarson

  • I post occasionally
  • **
  • Posts: 110
  • Karma: 5
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.4.22
Re: Error with Outbound Mail Settings.
May 14, 2010, 06:04:28 am
I have recently discovered that my SMTP provider does limit the total number of emails to 200 per hour. I do understand why there is a need for this, however this places an impossible restriction on the amount of 'marketing' emails that can be sent via CiviMail.

Could anyone point me in the direction of any settings etc that limit the number of emails that CiviMail/CiviCRM sends in a given period. Google does help; but some advice from the experts would be great.
“Anyone who has never made a mistake has never tried anything new.” - Albert Einstein
"If you are travelling at the speed of light and you turn on your headlights, would they work?" - Unknown

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Error with Outbound Mail Settings.
May 14, 2010, 06:38:38 am
See civicrm/admin/mail?reset=1 (i.e. http://mysite.com/civicrm/admin/mail?reset=1 )

CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Windows and IIS installations »
  • Error with Outbound Mail Settings.

This forum was archived on 2017-11-26.