Mercury邮件和php电子邮件创建脚本

时间:2012-04-13 04:27:48

标签: php html email wamp

我需要帮助创建一个脚本或程序,当他们在表单上注册时可以将用户添加到我的水银邮件服务器。我正在使用基本的php帖子表单,它确实创建了运行帐户所需的所有文件,但是当我打开水银邮件时,新用户帐户尚未添加到帐户列表中。并且新帐户无法登录。

请协助我创建客户端电子邮件注册脚本或程序,以便我的客户可以轻松地在我的服务器上免费创建电子邮件。

链接到表单代码:http://pastebin.com/bEtv4eck

链接到php邮政编码:http://pastebin.com/rwBJatap

P.S。我有脚本工作,它可以创建新用户和一切,但它不允许登录,除非重新启动电子邮件服务器。有什么方法可以解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

您还需要在PMAIL.USR文件中添加用户

尝试

const MERCURY_PATH = 'C:\Apache\xampp\MercuryMail';
$userFile = MERCURY_PATH . DIRECTORY_SEPARATOR . "PMAIL.USR";
$mailDir = MERCURY_PATH . DIRECTORY_SEPARATOR . "MAIL";

$newName = "Baba Konko";
$newUsername = "baba";
$newPassword = "pass";
$host = "localhost";

if (! is_writeable ( $userFile )) {
    die ( "You don't have permission to  Create new User" );
}

if (! is_writeable ( $mailDir )) {
    die ( "You don't have permission to add mail folder" );
}

// Check if user exist

if (is_file ( $userFile )) {
    $users = file ( $userFile );

    foreach ( $users as $user ) {
        list ( $status, $username, $name ) = explode ( ";", strtolower ( $user ) );

        if (strtolower ( $newUsername ) == $username) {
            die ( "User Already Exist" );
        }
    }
}

$userData = "U;$newUsername;$newName";
$fp = fopen ( $userFile, "a" );

if ($fp) {
    fwrite ( $fp, $userData . chr ( 10 ) );
    fclose ( $fp );
}

$folder = $mailDir . DIRECTORY_SEPARATOR . $newUsername;
if (! mkdir ( $folder )) {
    die ( "Error Creating Folder" );
}

$pm = '# Mercury/32 User Information File' . chr ( 10 );
$pm .= 'POP3_access: ' . $newPassword . chr ( 10 );
$pm .= 'APOP_secret: ' . $newPassword . chr ( 10 );

$pmFile = $folder . DIRECTORY_SEPARATOR . 'PASSWD.PM';
file_put_contents ( $pmFile, $pm );

答案 1 :(得分:0)

在对pmail.usr和mail,目录进行更改后尝试使用RELOAD USERS。