网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 邮件系统软件 > Qmail
本月文章推荐
.如何防止邮件服务器被滥用.
.企业Sendmail邮件服务器的创建.
.Linux上使用Sendmail群集的高可用.
.Mutt 电子邮件快速入门指南.
.Postfix+Qpopper+Openwebmail.
.基于Linux和Postfix的邮件系统的.
.对基于qmail的smtp用户验证的总结.
.架设防病毒、垃圾邮件网关.
.sendmail中限定用户邮箱大小的实.
.Red Hat Postfix中文FAQ.
.Red Hat 企业版4.1 + antivir-ma.
.FreeBSD下E-mail服务搭建.
.Postfix Ecartis HOWTO - 集成ec.
.Qmail域名相关问题一.
.FreeBSD4.7环境下构建中小企业Qm.
.SOLARIS+QMAIL+VPOPMAIL+IGENUS+.
.如何让postfix找到最佳MX记录.
.Postfix+Vm-pop3d+OpenWebMail.
.maildrop - Webmail dev problem.
.简易安装postfix邮件服务器.

如何列出vpopmail一个虚拟域下的所有用户

发表日期:2006-12-3


/*
* vpopmail2txt jieer xjb@bjsing.net
* URL: http://bycd.bjsing.net/vpopmail2txt.c
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "config.h"
#include "vpopmail.h"
#include "vauth.h"

struct vqpasswd *vpwd = NULL;
int conv_domain(char *);
int main(int n, char *cmd[])
{
if (n < 2 || n > 2) {
printf("vpopmail2txt [domainname|all]\n");
return 0;
}
if (strcasecmp(cmd[1], "all") == 0) {
DIR *mydir;
char domain[100];
struct dirent *mydirent;

if (chdir(VPOPMAILDIR) != 0) {
perror("vpopmail2txt: change dir to vpopmail home");
return (-1);
}
if (chdir(DOMAINS_DIR) != 0) {
perror("vpopmail2txt: change dir to vpopmail home");
return (-1);
}

mydir = opendir(".");
if (mydir == NULL) {
perror("vpopmail2txt: opendir failed");
return (-1);
}

while ((mydirent = readdir(mydir)) != NULL) {
if (strncmp(mydirent->d_name, ".", 1) == 0)
continue;
strncpy(domain, mydirent->d_name, 99);
printf("converting %s \t\t--", domain);
if (conv_domain(domain) != 0) {
printf("failed\n");
} else {
printf("done\n");
}
}
closedir(mydir);

} else
conv_domain(cmd[1]);

return 0;
}
int conv_domain(char *domain)
{
FILE *fp;
char buf[256];

vpwd = vauth_getall(domain, 1, 0);
if (NULL == vpwd) {
printf("empty", domain);
return -1;
}
snprintf(buf, 255, "%s.txt%c", domain, 0);
if ((fp = fopen(buf, "w")) == NULL) {
printf("can not open %s\n", buf);
return -2;
}
while (vpwd != NULL) {
fprintf(fp,"%s@%s:%s%s:%s\n", vpwd->pw_name, domain,
#ifdef CLEAR_PASS
"", vpwd->pw_clear_passwd,
#else
"{crypt}", vpwd->pw_passwd,
#endif
vpwd->pw_gecos);
vpwd = vauth_getall(domain, 0, 0);
}
fclose(fp);
return 0;
}


gcc -O2 -I/home/vpopmail/include vpopmail2txt.c -o vpopmail2txt -L/home/vpopmail/lib -lvpopmail

可能根据你的实际情况需要一些库,具体情况根据~vpopmail/etc下的inc_deps,lib_deps确定

如果你用db来存储用户数据,就不用这个程序了~vpopmail/domains/mydomain/下边有这样的列表。
,
上一篇:postfix 2.0.16的虚拟投递代理文档 人气:2802
下一篇:用于qmail-qfilter的附件过滤脚本 人气:2471
浏览全部Qmail/Sendmail/Postf的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐