Problem with creating new mailboxes

started at 07 Sep 2006 by Richard
  • Richard
    07 Sep 2006
    Since the upgrade of postfix to version 2.2 there has been a problem with the automatic creation of the mail directories. Postfix admin sends an email to the newly created email address which results in the creation of the maildir. However, postfix has become very strict in their acceptance of incoming email.

    The email being send is rejected because of the unauth pipelining being caused by postfix admin. Or in plain words, postfix admin is sending a lot of commands to postfix without listening for answers. The bug is noticed and solved in the source tree but it has been some time since there has been a release.

    I'll try to get a bugfix for the current 2.1.0 release out of the source tree and test it out.
  • Richard
    10 Sep 2006
    Ok, I've got it solved as far as I can tell. When testing this solution against postfix 2.2.3 with the strict pipelining settings the mailboxes get created on the system which means that new users don't have problems accessing their newly created mail address via POP3 or IMAP.

    You got to replace the function 'smtp_mail($to, $from, $data)' in the file functions.inc.php with the following:


    function smtp_mail ($to, $from, $data)
    {
       global $CONF;
       $smtpd_server = $CONF['smtp_server'];
       $smtpd_port = $CONF['smtp_port'];
       $smtp_server = $_SERVER["SERVER_NAME"];
       $errno = "0";
       $errstr = "0";
       $timeout = "30";
       
       $fh = @fsockopen ($smtpd_server, $smtpd_port, $errno, $errstr, $timeout);

       if (!$fh)
       {
          return false;
       }
       else
       {
          fputs ($fh, "EHLO $smtp_server\r\n");
          $res = smtp_get_response($fh);
          fputs ($fh, "MAIL FROM:<$from>\r\n");
          $res = smtp_get_response($fh);
          fputs ($fh, "RCPT TO:<$to>\r\n");
          $res = smtp_get_response($fh);
          fputs ($fh, "DATA\r\n");
          $res = smtp_get_response($fh);
          fputs ($fh, "$data\r\n.\r\n");
          $res = smtp_get_response($fh);
          fputs ($fh, "QUIT\r\n");
          $res = smtp_get_response($fh);
          fclose ($fh);
       } 
       return true;



    Also you need to add the following function to read the response from Postfix properly, add it anywhere in the functon file.


    function smtp_get_response ($fh)
    {
               $res ='';
               do
               {
                  $line = fgets($fh, 256);
                  $res .= $line;
               }           while (preg_match("/^\d\d\d\-/", $line));
               return $res;
    }



    I didn't make this up myself, I just copied the code that was needed from CVS.

    You can also donwload the complete functions.inc.php file from here.
  • Michael
    12 Nov 2006
    I just ran into this. Good catch
  • mshad
    21 Sep 2008

    Postfixadmin hangs up while creating mailboxes. I don't have any subdirs under /usr/local/virtual.

    I am using the correct functions.inc.php.

    Any thoughts?

  • Richard
    22 Sep 2008

    Try to send an email from the command line or an outside server. If everything is configured correctly a maildir should appear.

Reply

You must log in to post.