Support » Plugin: Postman SMTP Mailer/Email Log » Call to undefined function str_getcsv()

  • Resolved micb

    (@micb)


    Hello,

    I just installed this plugin following your instructions. When I try to send a test email, the following error shows up:

    Fatal error: Call to undefined function str_getcsv() …/plugins/postman-smtp/Postman/OAuthSmtpEngine.php on line 111

    No emails at all are sent from the web site any further.

    Thanks in advance!

    https://wordpress.org/plugins/postman-smtp/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jason Hendriks

    (@jasonhendriks)

    str_getcsv() is a PHP 5.3 function. I use it to tokenize a comma-separated list of e-mail addresses. I’ll have to find a replacement.

    Thanks for the bug report!

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    Fixed:
    Fatal error: Call to undefined function str_getcsv() => Replaced with PHP 4 function

    Before I release a new version, would you please grab the development version and try it out.

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    I found this page that says Zend Framework 2.3 requires PHP 5.3.23 or above.

    I’ve installed PH 5.2.17 on my computer but it’s probably going to be a little while longer until I get a working version for your version of PHP..

    Hi,

    I just added the following lines on line 111 of file OAuthSmtpEngin.php:

    if(!function_exists('str_getcsv')) {
        function str_getcsv($input, $delimiter = ',', $enclosure = '"') {
    
            if( ! preg_match("/[$enclosure]/", $input) ) {
              return (array)preg_replace(array("/^\\s*/", "/\\s*$/"), '', explode($delimiter, $input));
            }
    
            $token = "##"; $token2 = "::";
            //alternate tokens "3434", "3535", "%%";
            $t1 = preg_replace(array("/\\\[$enclosure]/", "/$enclosure{2}/",
                 "/[$enclosure]\\s*[$delimiter]\\s*[$enclosure]\\s*/", "/\\s*[$enclosure]\\s*/"),
                 array($token2, $token2, $token, $token), trim(trim(trim($input), $enclosure)));
    
            $a = explode($token, $t1);
            foreach($a as $k=>$v) {
                if ( preg_match("/^{$delimiter}/", $v) || preg_match("/{$delimiter}$/", $v) ) {
                    $a[$k] = trim($v, $delimiter); $a[$k] = preg_replace("/$delimiter/", "$token", $a[$k]); }
            }
            $a = explode($token, implode($token, $a));
            return (array)preg_replace(array("/^\\s/", "/\\s$/", "/$token2/"), array('', '', $enclosure), $a);
    
        }
    }

    With this change I can send a test email to myself, but usual notifications from the platform are still not sent. Furthermore, my test emails still land in the SPAM folder…

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    .. that’s interesting. I guess you didn’t download my code, I did (more or less):

    if(!function_exists('str_getcsv')) {
    	$fh = fopen ( 'php://temp', 'r+' );
    	fwrite ( $fh, $email );
    	rewind ( $fh );
    
    	$t = fgetcsv ( $fh );
    
    	fclose ( $fh );
    } else {
    	$t = str_getcsv ( $email );
    }
    Plugin Author Jason Hendriks

    (@jasonhendriks)

    I thought for sure you were going to run into

    Fatal error: Class 'ArrayObject' not found

    But I guess your PHP has the SPL extension installed.. I added this check in AdminController.php as a warning:

    public function create_admin_page() {
    
    	// test features
    	$sslRequirement = extension_loaded ( 'openssl' );
    	$splAutoloadRegisterRequirement = function_exists ( 'spl_autoload_register' );
    	$phpVersionRequirement = PHP_VERSION_ID >= 50300;
    	$arrayObjectRequirement = class_exists ( 'ArrayObject' );

    So, if you have no more errors, and you can send a test e-mail to yourself, the question now is why do other notifications not get sent?

    Question: In your test e-mail that you got, does your body say:
    ' - sent by Postman via internal engine'
    or
    ' - sent by Postman via wp_mail()'

    I actually try to send mail TWICE in case wp_mail() failed…

    Would you like to become a developer on the project, micb? I can give you write access to the repo.

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    I test with Contact Form 7 and the WordPress Lost Password function myself… maybe it’s plugin compatibility problem? What other ‘usual notifications’ are you talking about? I can download the plugins you’re using and try them in my dev environment.

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    Gah! >:-(

    You can’t send mail (no-one can send mail) cuz there is a bug:

    Notice: Undefined variable: authorizationToken in /Users/jasonhendriks/Documents/workspace-postman/PostmanSMTP/Postman/PostmanWpMail.php on line 27

    Fatal error: Call to a member function save() on a non-object in /Users/jasonhendriks/Documents/workspace-postman/PostmanSMTP/Postman/PostmanWpMail.php on line 27

    I’ll release 0.2.7 right away.

    Plugin Author Jason Hendriks

    (@jasonhendriks)

    Is this working for you now?

    Hi,

    Thanks for the update. I took a simpler way, which also works for now for me. But I will keep in mind your plugin which looks great!

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Call to undefined function str_getcsv()’ is closed to new replies.