ExtMail服务器社区's Archiver

lijianyu110 发表于 2004-5-27 01:28

postfix 在线申请邮箱

小弟现在想做POSTFIX的在线申请, 得到用户名插入数据库倒是简单,但是产生有什么办法产生用户的系统邮箱文件呢?PHP不能调用 cyradm 中的命令

/**********************************************/
cyradm --user cyrus localhost
IMAP Password:
jyli.com> sq user/jyli STORAGE 10485760
/**********************************************/

请各位大侠指教.

hzqbbc 发表于 2004-5-27 04:46

[quote]【[b]在 lijianyu110 发表的大作中提到:[/b]】
:小弟现在想做POSTFIX的在线申请, 得到用户名插入数据库倒是简单,但是产生有什么办法产生用户的系统邮箱文件呢?PHP不能调用 cyradm 中的命令

:/**********************************************/
:cyradm --user cyrus localhost
[/quote]

系统用户?这个有点难度咯。要root权限哦。。。好象sudo可能可以实现,但。。。。
不要用unix account啦。。危险危险。

lijianyu110 发表于 2004-6-9 23:25

[quote]【[b]在 hzqbbc 发表的大作中提到:[/b]】


:系统用户?这个有点难度咯。要root权限哦。。。好象sudo可能可以实现,但。。。。
:不要用unix account啦。。危险危险。
[/quote]
听说用这个
  "perl -MCyrus::IMAP::Shell -e shell -- --user cyrus localhost " 等命令
就可以调用cyradm的相关命令来管理油箱,请问有没有这方面的资料。

hzqbbc 发表于 2004-6-11 15:37

[quote]【[b]在 lijianyu110 发表的大作中提到:[/b]】

:听说用这个
:  "perl -MCyrus::IMAP::Shell -e shell -- --user cyrus localhost " 等命令
:就可以调用cyradm的相关命令来管理油箱,请问有没有这方面的资料。
[/quote]

search.cpan.org

lijianyu110 发表于 2004-6-25 21:50

[quote]【[b]在 hzqbbc 发表的大作中提到:[/b]】


:search.cpan.org
[/quote]
总算找到一偏文章。解决这个在线申请问题
http://tomster.org/geek/freebsdcookbook/ar01s03.html

lijianyu110 发表于 2004-6-25 21:52

#!/usr/bin/perl -w
#
# This will create a new mailbox and set a quota on the new user. Just be
# sure that you installed the Cyrus::IMAP perl module. If you did
# 'make all && make install' or installed Cyrus using the FreeBSD ports you
# don't have to do anything at all.
#
# Change the params below to match your mailserver settins, and
# your good to go!
#
# Author: amram@manhattanprojects.com
#
# modified by Tom Lazar tom@tomster.org on 2003-08-26 to use
# a tab separated user - passwd inputfile instead of the standardpassword

use Cyrus::IMAP::Admin;

#
# CONFIGURATION PARAMS
#
my $cyrus_server = "localhost";
my $cyrus_user = "cyrus";
my $cyrus_pass = "CYRUSPASSWORD";

# 100 Megs
my $quota_size = "1000000";

my $mechanism = "login";

#
# EOC
#

if (!$ARGV[0]) {
die "Usage: $0 [user to add] passwd
";
} else {
$newuser = "$ARGV[0]";
$newpasswd = "$ARGV[1]";  
}

sub createMailbox {

my ($user, $subfolder) = @_;

my $cyrus = Cyrus::IMAP::Admin->new($cyrus_server);
$cyrus->authenticate($mechanism,'imap','',$cyrus_user,'0','10000',$cyrus_pass);

if ($subfolder eq "INBOX") {
  $mailbox = "user.". $user;
} else {
  $mailbox = "user.". $user .".". $subfolder;
}

$cyrus->create($mailbox);
if ($cyrus->error) {
  print STDERR "Error: ", $mailbox," ", $cyrus->error, "
";
} else {
  print "Created Mailbox: $mailbox
";
}

}

sub setQuota {

my ($user) = @_;

my $cyrus = Cyrus::IMAP::Admin->new($cyrus_server);
$cyrus->authenticate($mechanism,'imap','',$cyrus_user,'0','10000',$cyrus_pass);

$mailbox = "user.". $user;
$cyrus->setquota($mailbox,"STORAGE",$quota_size);
if ($cyrus->error) {
  print STDERR "Error: ", $mailbox," ", $cyrus->error, "
";
} else {
  print "Setting Quota: $mailbox at $quota_size
";
}

}

print "Adding User: ", $newuser, "
";

createMailbox($newuser,'INBOX');
createMailbox($newuser,'Sent');
createMailbox($newuser,'Trash');
createMailbox($newuser,'Drafts');
createMailbox($newuser,'Junk');

setQuota($newuser);

# This portion below will set a password for the user you wanted to
# add.

system "echo ". $newpasswd ." > .saslpass.tmp";
system "saslpasswd2 -p $newuser < .saslpass.tmp";
print "Generated Password: Completed
";
unlink(".saslpass.tmp");

hzqbbc 发表于 2004-6-26 21:47

[quote]【[b]在 lijianyu110 发表的大作中提到:[/b]】
:#!/usr/bin/perl -w
:#
:# This will create a new mailbox and set a quota on the new user. Just be
:# sure that you installed the Cyrus::IMAP perl module. If you did
[/quote]

哦。干得好!加精华!:)

lijianyu110 发表于 2004-8-28 21:34

今天一人在办公室值班,看见这个网站。
http://www.1931-9-18.org/main/default.asp
看了这个flash
http://www.lizi.cc/mambo/index.php?option=com_docman&task=docclick&Itemid=62&bid=49&limitstart=0&limit=11
忍不住热泪夺眼而出。

Helvin 发表于 2004-9-17 23:21

иノ�F这个

http://email.uoa.gr/projects/cyrus/autocreate/index.html

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.