• I migrate production (linux) to localhost (WAMP) often to do test & dev work. That requires remember to change the Temporary Directory in Post SMTP > Settings > Advanced to a valid Windows path. I forgot to do that today before invoking the send_message() functionality and the website just hanged with the following log:

    PHP Warning:  mail(): SMTP server response: 530-5.7.0 Authentication Required. Learn more at
    530 5.7.0  https://support.google.com/mail/?p=WantAuthError o21sm2812138ljg.71 - gsmtp in plugins\post-smtp\Postman\Extensions\Core\Notifications\PostmanMailNotify.php on line 12
    ERROR PostmanWpMail: Exception code=0 message=Could not create lockfile /tmp/.postman.lock

    To make the backend operational once again, had to comment out the line 12 of the error above to become able to fix the path in the UI backend:

    //mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', 'post-smtp' ), $message , '', "-f{$to_email}" );

    Please consider adding a more gracefully way of checking/handling an incorrect path to tmp directory.

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter alx359

    (@alx359)

    Briefly looked into this, and the issue appears to be with this piece of code:

    \post-smtp\Postman\PostmanUtils.php line 218

    static function lock() {
        if ( PostmanState::getInstance()->isFileLockingEnabled() ) {
            $attempts = 0;
            while ( true ) {
                // create the semaphore
                $lock = PostmanUtils::createLockFile();
                if ( $lock ) {
                    // if we got the lock, return
                    return;
                } else {
                    $attempts ++;
                    if ( $attempts >= 10 ) {
                        #alx359 added line: ensure FILE_LOCKING_ENABLED becomes false, to avoid an endless loop of blocked processes
                        PostmanState::getInstance()->setFileLockingEnabled( false );
                        
                        throw new Exception( sprintf( 'Could not create lockfile %s', '/tmp' . '/.postman.lock' ) );
                    }
                    sleep( 1 );
                }
            }
        }
    }

    Explanation:
    When FILE_LOCKING_ENABLED was saved as true in wp_options, but meanwhile the path has become somehow invalid (in my case, during migration from Linux to WAMP), the lock() appears to enter in an endless loop of dead-end processes that crashes the server at the end. That means the isFileLockingEnabled() check has become a fake, so resetting FILE_LOCKING_ENABLED in wp_options is required via setFileLockingEnabled(false);. Doing so before throwing the exception seems a good place to do it, and it fixes the issue my end.

    Thanks.

Viewing 1 replies (of 1 total)

The topic ‘Invalid tmp dir hangs website during mail send’ is closed to new replies.