存档

‘Mail’ 分类的存档

命令行发送有附件的邮件

2008年12月1日 wd 没有评论

命令行下面发送邮件比较简单,恐怕都会使用。

$ echo "hello .. " | mail -s subject xxx@abc.com
$ cat /path/to/file | mail -s subject xxx@abc.com
$ mail -s subject xxx@abc.com << EOF
hi
the end..
EOF

上面这些方法都可以发送邮件。还有一种方法。

$ cat a.txt
Subject: test
From: xxx@abc.com
To: xxx@abc.com
 
hi
sdfsdfsdf
the end.
$ cat a.txt | sendmail -t

这样可以把邮件头信息写到文件里面的,你也可以用 php,perl 来打印类似的信息给 sendmail -t ,让他来发。

那么如果有附件应该怎么办?可以使用 uuencode。

$ uuencode a.txt a.txt | mail -s test xxx@abc.com
$ (cat a.txt; uuencode b.txt b.txt; cat c.txt) |sendmail -t

应该说的很明白了吧?

分类: Mail 标签:

ORA-00257 和 ORA-19815

2008年9月6日 wd 没有评论

这几天遇到了这两个错误,记录一下。

使用 perl 的 DBI 连接的时候,会提示 ora-00257 错误,这个用 三qlplus 估计也是一样的错误,注意时远程连接才出错。

DBI connect('host=db8.xxx;sid=nirv3','sirenmon',...) failed: ORA-00257: archiver error. Connect internal only, until freed. (DBD ERROR: OCISessionBegin) at ./check_sdsdb line 26
CRITICAL : Can't connect "db8.sds.cnb.yahoo.com"

同时,数据库的alert 里面有下面的信息

Errors in file /home/oracle/app/diag/rdbms/nirv/nirv3/trace/nirv3_arc1_9507.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 268435456000 bytes is 100.00% used, and has 0 remaining bytes available.
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
ARCH: Archival stopped, error occurred. Will continue retrying
ORACLE Instance nirv3 - Archival Error

登陆上数据库看看

SQL&gt; show parameter archive
 
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
archive_lag_target                   integer                0
log_archive_config                   string                 dg_config=(stb1)
log_archive_dest                     string
log_archive_dest_1                   string                 location="USE_DB_RECOVERY_FILE
log_archive_dest_10                  string
log_archive_dest_2                   string
log_archive_dest_3                   string
log_archive_dest_4                   string
log_archive_dest_5                   string
log_archive_dest_6                   string
log_archive_dest_7                   string
 
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
log_archive_dest_8                   string
log_archive_dest_9                   string
log_archive_dest_state_1             string                 ENABLE
log_archive_dest_state_10            string                 enable
log_archive_dest_state_2             string                 ENABLE
log_archive_dest_state_3             string                 enable
log_archive_dest_state_4             string                 enable
log_archive_dest_state_5             string                 enable
log_archive_dest_state_6             string                 enable
log_archive_dest_state_7             string                 enable
log_archive_dest_state_8             string                 enable
 
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
log_archive_dest_state_9             string                 enable
log_archive_duplex_dest              string
log_archive_format                   string                 %s_%t_%r_%a.arc
log_archive_local_first              boolean                TRUE
log_archive_max_processes            integer                4
log_archive_min_succeed_dest         integer                1
log_archive_start                    boolean                FALSE
log_archive_trace                    integer                0
standby_archive_dest                 string                 ?/dbs/arch
 
SQL&gt; select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIV STATUS                           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------
         1          1     221250   52428800          1 YES    INACTIVE                            5082709437 05-SEP-08
         2          1     221252   52428800          1 NO     INACTIVE                            5082713458 05-SEP-08
         3          2     270972   52428800          1 YES    INACTIVE                            5082699510 05-SEP-08
         4          2     270975   52428800          1 NO     CURRENT                             5082713581 05-SEP-08
         9          1     221251   52428800          1 NO     INACTIVE                            5082712943 05-SEP-08
        10          2     270973   52428800          1 YES    INACTIVE                            5082705151 05-SEP-08
        11          1     221253   52428800          1 NO     CURRENT                             5082713765 05-SEP-08
        12          2     270974   52428800          1 NO     INACTIVE                            5082711887 05-SEP-08
        13          3     275581   52428800          1 NO     INACTIVE                            5082712519 05-SEP-08
        14          3     275582   52428800          1 NO     CURRENT                             5082713078 05-SEP-08
        15          3     275579   52428800          1 NO     INACTIVE                            5082710114 05-SEP-08
 
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIV STATUS                           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------
        16          3     275580   52428800          1 NO     INACTIVE                            5082711321 05-SEP-08
 
12 rows selected.
 
SQL&gt; ????select value from v$diag_info where name ='Diag Trace';
 
VALUE
------------------------------------------------------------------------------------------------------------------------------------------------------
/home/oracle/app/diag/rdbms/nirv/nirv3/trace
 
SQL&gt; select * from V$FLASH_RECOVERY_AREA_USAGE;
 
FILE_TYPE                                PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
---------------------------------------- ------------------ ------------------------- ---------------
CONTROL FILE                                              0                         0               0
REDO LOG                                                  0                         0               0
ARCHIVED LOG                                            100                         0           13109
BACKUP PIECE                                              0                         0               0
IMAGE COPY                                                0                         0               0
FLASHBACK LOG                                             0                         0               0
FOREIGN ARCHIVED LOG                                      0                         0               0
 
7 rows selected.
 
SQL&gt; show parameter db_recovery_file_dest_size
 
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
db_recovery_file_dest_size           big integer            250G
SQL&gt; show parameter DB_RECOVERY_FILE_DEST
 
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
db_recovery_file_dest                string                 /sds/oradata
db_recovery_file_dest_size           big integer            250G
SQL&gt; alter system set db_recovery_file_dest_size=300G;  
 
System altered.
 
SQL&gt; show parameter DB_RECOVERY_FILE_DEST
 
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
db_recovery_file_dest                string                 /sds/oradata
db_recovery_file_dest_size           big integer            300G
SQL&gt; select * from V$FLASH_RECOVERY_AREA_USAGE;
 
FILE_TYPE                                PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
---------------------------------------- ------------------ ------------------------- ---------------
CONTROL FILE                                              0                         0               0
REDO LOG                                                  0                         0               0
ARCHIVED LOG                                          83.41                         0           13115
BACKUP PIECE                                              0                         0               0
IMAGE COPY                                                0                         0               0
FLASHBACK LOG                                             0                         0               0
FOREIGN ARCHIVED LOG                                      0                         0               0
 
7 rows selected.

可以看到空间是 83% 了,数据库应该就好了。不过这个是治标不治本的操作,需要把archive log删掉才行,具体怎么搞我也不会。。。汗。。

分类: Mail 标签:

sendmail 中自动抄送某个用户的邮件给别人

2007年6月26日 wd 没有评论

sendmail有个 /etc/aliases 配置文件,在里面可以给某个帐号设置alias,这样给这个alias发的邮件,都会给设置好的用户转发过去。要知道sendmail的帐号是和系统帐号联系在一起的,添加mail帐号得给系统添加帐号(qmail可以实现虚拟用户,或许sendmail也可以,而我不知道罢了)。而这个alias帐号却不是必须有得有系统帐号的,只要设置了alias,就可以给alias用户发邮件,就好像系统真有这么一个帐号一样。

关于 /etc/aliases 文件,这里有个文章有说明。下面复制几个例子。

# RFC 822 规定每个域名都需要有一个 "postmaster" 
postmaster      : root
 
# 将 postmaster 的邮件都转发给 root 帐号,当然你下面还可以将root帐号的邮件在转发给别人。
 
# 转发也可以转发到文件
# 比如这个,都说了nobody了还给发邮件,邮件都丢掉
nobody          : /dev/null
 
# 也可以通过管道作为另一个程序的输入
# 比如给procmail,它能实现的功能可就多了,比如可以根据邮件大小转发到不同的用户,或者调用spamassian、clamav来查垃圾邮件和病毒等
# 一个自动的bug跟踪程序
program-bugs: |/usr/local/bin/program-bug-tracker
 
# 也可以转发到多个帐号,用逗号分隔就可以
project-list: johndoe@host1.uiuc.edu,jsmith@host2.uiuc.edu,someone@host.purdue.edu

可以看到功能还是很强悍的,尤其是可以 pipe 到程序,procmail、maildrop都是很不错的过滤程序,能实现很多其他的功能。

标题的要求是“抄送”某个帐号的邮件给别的用户,有点类似监控的意思。怎么实现呢?可能第一个想到的就是类似下面这种方法:

somebody:other1,other2,somebody

这样是不是就能实现抄送呢?这样会造成死循环,呵呵。

看样子似乎只能通过pipe到程序实现了,看procmail、maildrop的文档还不够头疼的。其实还有个简单的方法,就是 .forward 文件。

.forward 文件位于用户的 home 下面,权限是 600 。他的功能和 /etc/aliases 文件类似,不过是 aliases 文件只能由root用户来修改,而 .forward 文件用户自己就可以修改。除了上面aliases能做到的事情外,他还多了一个功能,就是标题要求的功能。

按照标题的要求,只需要在 somebody 用户的 .forward 文件中放入下面的内容就可以了。

\\somebody
other1
other2

要注意 somebody 前面的那个\,就是用来防止转发死循环的。加了\之后,给somebody转发的时候会忽略该用户的 .forward 文件。

分类: Linux, Mail 标签: ,

mutt的两个问题以及解决办法

2006年11月1日 wd 没有评论

mutt用了一段时间之后发现对方发过来的附件的名字都是乱码,多次之后就觉得比较郁闷,每次都得自己修改名字,还得猜文件类型,很郁闷。google了一下,发现了解决办法,是因为mutt默认使用的是rfc2331来解码的,所以添加一个set rfc2047_parameters=yes就可以了,这样对方发过来的邮件就可以正常显示文件名称了。但是同时从那个网址得知,我发出去的附件,也是用rfc2331来编码的,这样到了对方那里,显然会乱码了。测试了一下,outlook里面提示有附件,可是打开是乱码,并且附件名称也不是实际的附件名称。foxmail里面不提示有附件,内容后面会显示几个乱码。

按照前面那个网址,找到了mutt的补丁,尝试了半天,不能在muttng上面正常使用,没办法只好不用muttng用mutt了。打上补丁之后,设置了 set create_rfc2047_parameters=yes  发出去的邮件就正常了。在mutt的patch list列表里面找到sidebar补丁,给mutt打了sidebar的补丁,用起来也还行了。同时,也把我的mutt升级到了1.5.13,比源里面的都新了。呵呵。

此外,还有一个问题就是如何对应不同的账号使用不同的smtp server。 本来从网上找了一个文章说到了这个操作如何实现,我也照搬了,发现似乎可以实现这个功能。可是最近才发现,我完全错了,实际上用的总是msmtp里面设置的那个default smtp server,郁闷坏啦,给头以及同事发了好多邮件了,用的都是我的gmail邮箱。

现在我已经解决了这个问题,用的是send-hook,如下。
send-hook . ‘my_hdr from:wd@aaa.com’
send-hook . ‘set sendmail=”/usr/bin/msmtp -a gmail”‘
send-hook ‘~t .*@bbb\.com\.cn$’ ‘my_hdr from:stef@bbb.com.cn’
send-hook ‘~t .*@bbb\.com\.cn$’ ‘set sendmail=”/usr/bin/msmtp -a bbb”‘

这样,针对不同的mail,使用不同的sendmail程序。

发现mutt发送邮件的时候使用的是我的gmail邮箱的时候,我很郁闷,再加上发现他发送的附件在别人那里居然不认,让我就更郁闷了。立刻安装了thunderbird,并且设置好了他,打算以后就用他了。但是发现我已经习惯了mutt了,所以还是回头来给mutt打了补丁,做了修改,让他按照我的习惯来了。 用thunderbird后发现,很多事情不能按照我的意思来,很郁闷。

分类: Mail 标签: , , , ,

Qmail邮件队列工作原理zz

2006年3月30日 wd 没有评论

http://www.gbunix.com/htmldata/2005_06/15/25/article_1223_1.html

以下是qmail的数据流简图

qmail-smtpd — >>qmail-queue —>> qmail-send <<— qmail-rspawn <<— qmail-remote
                         /              |
      qmail-inject _/ qmail-clean \_ qmail-lspawn <<— qmail-local

   qmail中,每一条消息都发送到中央队列等待发送,由qmail-queue进程控制。它在以下情况被调用:
   1、当产生本地消息时,qmail-inject进程调用qmail-queue。
   2、qmail-smtpd准备SMTP协议下的投递邮件任务时调用它。
   3、向前(forwarded)发送邮件时,qmail-local调用它。
   4、退回邮件时,qmail-send调用它。

   每封邮件接着由qmail-lspawn 和qmail-rspawn协助qmail-sned进程完成投递,最后由qmail-clean清除邮件队列。这四个进程是系统由始至终都在运行的,十分重要。

由smtpd从域外接受邮件之后,会交给queue处理(也就是2),之后转到qmal-send,然后看是域内还是域外,域内用qmail-lspawn,域外用qmail-rspawn。域内邮件调用qmail-local处理,如果遇到.qmail文件转发邮件(也就是上面的3),还会交给queue处理,如果没有,就直接投递给用户(?)。域外邮件调用qmail-remote处理,如果对方拒收邮件,他就会产生一个新的邮件(bounce),交给qmail-send,然后交给queue(也就是4?)。

本地用户发送mail的时候调用qmail-inject,然后交给queue(也就是1)。

有几个问题。
1  收到域外邮件之后,判断本机是否有这个用户后才接受邮件呢,还是先接受进来放到queue里等qmail-local处理的时候再说?

2  qmail-clean这个程序是怎么工作的?实时扫描queue的文件夹?

分类: Mail 标签:

邮件如何从A点到达B点zz

2006年3月30日 wd 没有评论

当一个主机上的用户想要发送一个邮件给另一个主机上的用户时, 许多事情发生了, 这个场景后面的东西很多是不必要知道的那么确切的.

假设一个用户 Alice, alice@alpha.example.com 想要发送一个邮件给 Bob, bob@beta.example.com, 下面是发送接收过程:

1. Alice 用她的邮件用户代理(MUA)编写邮件, 比如使用 mutt 或者 pine. 她在 To 这一栏指定接收者, Subject 这一栏填写邮件主题, 加上邮件本身的文本部分. 整个邮件看起来是下面这样的:

    To: bob@beta
    Subject: lunch

    How about pizza?

2. 当她觉得这封邮件已经满意之后, 她指派 MUA 发送邮件.

3. 这时候, MUA 会加上附加的邮件头部分, 比如日期 Date 和邮件ID(Message-Id) 并且修改Alice输入的值(例如, 将 bob@beta 替换为”Bob <bob@beta.example.com>”) 下一步, MUA 将邮件注入邮件系统. 有两种方式进行注入: MUA 运行一个由邮件系统提供的为注入邮件为目的的程序; 或者使用SMTP协议和本地或者远程邮件服务器建立连接, 举个例子, 我们假定 MUA 使用本地注入程序将邮件传送给 MTA, 对于不同的MTA, 注入细节都是不同的, 不过对于UNIX系统, 使用sendmail 程序注入已经成了事实上的标准. 使用这种方式, MUA 可以将邮件头和邮件主体放置在一个文件内, 由空行分隔, 然后传递这个文件到 sendmail 程序.

4. 如果注入成功–邮件句法正确, 并且 sendmail 调用适当–那么现在邮件已经在 MTA 的职责内了. 不同的 MTA 细节是完全不同的, 通常MTA首先检查邮件头决定邮件将发往何处. 然后建立一个到主机beta的SMTP连接, 转发邮件给 beta 系统上的MTA. SMTP对话要求邮件被分成两部分发送: 信封, 这个部分确定了接收者的地址(bob@beta.example.com)和返回地址(alice@alpha.example.com), 以及邮件本身, 包括邮件头和邮件主体.

5. 如果beta主机的MTA拒绝这个邮件, 可能原因是在beta系统上没有这个bob用户, 在alpha 上的MTA发送一个反弹邮件给返回地址, 也就是 alice@alpha, 通知她邮件发送出现了问题.

6. 如果 beta主机上的 MTA接收了邮件, 它查看接收者地址, 决定是发送给本地local 还是远程 remote系统的邮件. 这个例子里面, 接收者是本地用户, 然后MTA或者传送邮件给 mail delivery agent (MDA), 比如 /bin/mail或者传送给 procmail.

7. 如果传输失败了, 可能是Bob的邮箱超过了使用限额, beta 主机上的 MTA 将发送一个反弹信息给信封上的返回地址, 即 alice@alpha.

8. 如果传输成功, 邮件将在Bob的邮箱中等待, 直到他使用MUA来阅读和显示邮件.

分类: Mail 标签:

Howto Qmail with spamassassin

2006年1月16日 wd 没有评论

http://sylvestre.ledru.info/howto/howto_qmail_spamassassin.php

By Sylvestre Ledru June 2003
Version francaise
Return to the linux page

(02/04/2002), Bug fix :
I just add a little bug fix for some OS which remove the +x on qmail-queue (the qmail-scanner is not concerned)
(01/11/2003), Qmail-scanner :
I had a new way of calling spamassassin client using qmail-scanner.
(23/07/2003), Preferences :
Matthew Francis sent me a quite good howto explaining how to get user preferences for spamassassin. It is available here.
(08/06/2003), Localisation :
If you want to change the language of the spam report (ie why the email has been tagged as a spam), just change the locales to your language (dpkg-reconfigure locales under debian) and install gettext (apt-get install gettext) and you will have the appropriate version (french for example)…
(11/03/2005), Update :
After almost two years without updates, my other howto about qmail is much more complet and uptodate, I clean this one :
- first method deprecated
- new version of spamassassin 3.0.X
- use of netqmail instead of qmail
- new version of qmail-scanner with the q-s-st patch (activation of Spamassassin just for a domain)

If you like this howto and you want to thank me for my work : here is my wishlist on Amazon – France or my Amazon US wishlist :)
If you are a corporation and you make some business thanks to my howto, we’ll love to have a present from you (or just tell me who is using my howto).
Thank to Scott Kinkade for his cash donation. I really do appreciate.

If you want more informations about the intallation of qmail, I wrote a long howto about.
I wrote this howto because there is a lack of documentation about qmail with spamassassin.

This howto has been designed for qmail with vpopmail but it should work without a lot of modifications with something else than vpopmail.

Spamassassin is a very powerfull program which checks if the receveid email is a spam or not. The analys is based on a list of mark. If the sum of all the mark exceed a specified amount (for example 5), the email will be tagged (****SPAM**** in the topic).
With this, it is very easy to create a rule which will move all emails into a specific directory (i.e. trash:)

If you want to link Qmail with spamassassin, it is quite easy.
First, install spamassassin and install razor and pyzor if you want to use it.
Under debian :
apt-get install spamassassin You should use the “debian unstable or testing” version of spamassassin which, most of the time, will find more spam.

Under other system (Redhat, Suse, Solaris …) : The latest version of spamassassin today is the version 3.0.2. The installation is almost the same, only a few directives changed.
wget http://useast.spamassassin.org/released/Mail-SpamAssassin-2.55.tar.gz
tar -zxvf Mail-SpamAssassin-2.55.tar.gz
cd Mail-SpamAssassin-2.55
perl Makefile.PL
make
make install
cp spamd/debian-rc-script.sh /etc/init.d/spamassassin You can replace debian by redhat, solaris, netbsd, suse …
chmod +x /etc/init.d/spamassassin

Then, edit /etc/spamassassin/local.cf
Version 2.5X :
required_hits 6.0
rewrite_subject 1
report_header 1
use_terse_report 1
defang_mime 1
dns_available yes
dcc_add_header 1
use_pyzor 1 (Only if you have installed pyzor)
use_razor2 (Only if you have installed razor2)
use_dcc 1
Version 3 :
#Number of points to tag the spam required_hits 5.0 # Add the result in the header always_add_headers 1 # change the subject rewrite_subject 1 report_safe 1 use_terse_report 1 # dns checks (warning : increase the process length) dns_available yes dcc_add_header 0 # Don’t skip the relay black list skip_rbl_checks 0 use_dcc 1 dcc_timeout 10 # Remote verification use_pyzor 1 pyzor_timeout 10 pyzor_add_header 1 # Never from the previous results auto_learn 1 # use the bayes filter use_bayes 1 # Where spamassassin must store these informations : bayes_path /var/qmail/spamassassin/ # Where he stores the auto white list results : auto_whitelist_path /var/qmail/spamassassin/auto_whitelist
If you want to have detailled information about spamassassin processing, add the line in the local.cf file : timelog_path /var/log/spamassassin, run the daemon with the -D option (so, specify it in the /etc/default/spamassassin file under debian), create the directory with appropriate rights (should be vpopmail). In the directory, you will have for each email a file which sum up the spamassassin process (it is a debug option !).

I use these rules. Feel free to change ! Documentation about this is available here : perldoc Mail::SpamAssassin::Conf

In /etc/default/spamassassin (if this file does not exist, create it)
Change ENABLED to 1, then add these options : – “-m 10 -v –auto-whitelist” for the version 2.5X.
- “-v -m 10 -u vpopmail –nouser-config” for the version 3
With that stuff, you can launch spamd which is bascilly a spamassassin deamon (provide great performances).
-m 10 => 10 childs
-v => vpopmail config
–auto-whitelist => Use auto whitelist (friend list)
Instead of spamassassin, you have to use spamc in order to test email.
There are some options “-c -u vpopmail” which enabled the creation of preferences for a domain or a user but it does not work very well for me.
/etc/init.d/spamassassin start

Next, the modification of qmail in order to check emails.
Basically, there are two kind of configuration for qmail :
- the fastest/easiest way is to change the qmail-queue in order to “introduce” the spamasssin check.Deprecated
- the cleanest way is to use qmail-scanner.
Changing the qmail-queue program
cp /var/qmail/bin/qmail-queue /var/qmail/bin/qmail-queue.orig
chown qmailq:qmail qmail-queue
chown qmailq:qmail qmail-queue.orig
chmod u+s qmail-queue.orig
chmod o+r,+x qmail-queue.orig qmail-queue Not fundamental but sometime it is necessary (depends the system)

mkdir /home/vpopmail/.spamassassin
cd /home/vpopmail
chmod 777 /home/vpopmail/.spamassassin

chown -R qmailq:qmail .spamassassin
chmod u=rwx,g=rx,o= /home/vpopmail/.spamassassin
Now, delete the content of the executable which manage the queue.
echo -n > /var/qmail/bin/qmail-queue
Then, edit the qmail-queue file and add this inside :
#!/bin/sh
/usr/bin/spamc | /var/qmail/bin/qmail-queue.orig
I agree that it is a quick/dirty method. It causes some issues with the injection of a bounce in the queue. (qmail-queue is not planned to work this way).
With qmail-scanner – Visit http://sylvestre.ledru.info/howto/howto_qmail_vpopmail.php for more informations
First, you have to patch qmail with the qmailqueue-patch or install netqmail which has already this plugin.
Qmail with the patch :
wget http://qmail.agarik.com/qmail-1.03.tar.gz
tar -zxvf qmail-1.03.tar.gz
cd qmail-1.03
wget http://qmail.mirrored.ca/moni.csi.hu/pub/glibc-2.3.1/qmail-1.03.errno.patch
wget http://sylvestre.ledru.info/howto/qmail/qmailqueue-patch
patch -p1 < qmail-1.03.errno.patch
patch -p1 < qmailqueue-patch
With netqmail :
wget http://qmail.agarik.com/netqmail-1.05.tar.gz
tar -zxvf netqmail-1.05.tar.gz
cd netqmail-1.05/
./collate.sh
cd netqmail-1.05
Add the QMAILQUEUE parameter to the /etc/tcp.smtp file :
127.0.0.1:allow,RELAYCLIENT=”",QMAILQUEUE=”/var/qmail/bin/qmail-scanner-queue.pl”
198.168.1.:allow,RELAYCLIENT=”",QMAILQUEUE=”/var/qmail/bin/qmail-scanner-queue.pl”
:allow,QMAILQUEUE=”/var/qmail/bin/qmail-scanner-queue.pl”
Rehash tcpserver :
/usr/local/bin/tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
And then, install qmail-scanner with qmail-scanner-st
. qmail-scanner-st is a patched version a qmail-scanner which enabled great features like auto delete/reject/quarantine spam over a specified score but also to select which scanners will be used for a domain and even for a user, then, it is possible to configure the spamassassin / antivirus just for one domain/user.
wget http://unc.dl.sourceforge.net/sourceforge/qmail-scanner/qmail-scanner-1.25.tgz wget http://xoomer.virgilio.it/j.toribio/qmail-scanner/download/q-s-1.25st-20050207.patch.gz
gunzip q-s-1.25st-20050207.patch.gz
tar -zxvf qmail-scanner-1.25.tgz
cd qmail-scanner-1.25/
patch -p1 < ../q-s-1.25st-20050207.patch
groupadd qscand
useradd -c “Qmail-Scanner Account” -g qscand -s /bin/false qscand
./configure –qs-user qscand –qs-group qscand –spooldir /var/spool/qmailscan –qmaildir /var/qmail –bindir /var/qmail/bin –qmail-queue-binary /var/qmail/bin/qmail-queue –admin-fromname “Mail admin” –admin postmaster –domain vladimir.avence.info –notify sender,admin,recips –local-domains `cat /var/qmail/control/rcpthosts | tr “\n” ” “` –silent-viruses auto –unzip 1 –add-dscr-hdrs 1 –archive 0 –redundant yes –log-crypto 0 –scanners “fast_spamassassin” –scanners-per-domain yes –sa-subject “*****SPAM*****” –sa-delete 5 –install 1
After the installation, if you want to change your preferences, you have to edit the /var/qmail/bin/qmail-scanner-queue.pl file. In this file, you can also add option for the spamassassin client.
If you want to enable/disable some scanners, edit the /var/spool/qmailscan/scanners_per_domain.txt
To rehash the scanner per domain file : /var/qmail/bin/qmail-scanner-queue.pl -p
To rehash the quarantine attachement file : /var/qmail/bin/qmail-scanner-queue.pl -g
trunks.ecranbleu.org:sa,ps,clamdscan_scanner

# sa = spamassassin
# ps = perl scanner

This should be enough to use SpamAssassin on the whole system.
I have to try to find how it can be linked with vpopmail in order to create preference for a specific domain or a specific user. (if someone knows : sylvestre@ecranbleu.org)

Problems :
- link with vpopmail
This howto is inspired and corrected from :

http://www.euronet.nl/users/erhnam/linux/qmail/qmail.htm.

分类: Mail 标签:

caphit qmail 配置

2006年1月16日 wd 没有评论

参考网址

http://lifewithqmail.org(中文版http://lifewithqmail.org/LWQ-CN.html)

http://qmail.te8.com/rpms/glibc-2.3.1/(patch下载地址)

http://www.fehcom.de/qmail/qmail.html

http://www.pipeline.com.au/staff/mbowe/isp/vpopmail-mysql.htm

http://bbs.chinaunix.net/forum/viewtopic.php?t=254662

ucspi-tcp

http://cr.yp.to/ucspi-tcp.html

ucspi-tcp-0.88.a_record.patch,ucspi-tcp-0.88.errno.patch,ucspi-tcp-0.88.nodefaultrbl.patch
(或者)ucspi-tcp-0.88.a_record.patch,ucspi-tcp-0.88.errno.patch,ucspi-tcp-0.88.nobase.patch
patch -d ucspi-tcp.xxx -p1 < ucspi-tcp-xxx.patch
make&&make setup check

daemontools

http://cr.yp.to/daemontools.html

daemontools-0.76.errno.patch
package/install
Adding svscanboot to inittab…init should start svscan now.

cmd5checkpw

http://www.fehcom.de/qmail/auth/cmd5checkpw-030_tgz.bin

make&&make setup

qmail 1.03

http://cr.yp.to/qmail.html

http://www.fehcom.de/qmail/qmail.html

http://www.fehcom.de/qmail/spamcontrol/spamcontrol-2311_tgz.bin

tar zxvf spamcontrol-2311_tgz.bin
编辑conf-spamcontrol
建立用户组
groupadd nofiles
useradd -g nofiles -d /var/qmail qmaild -s /sbin/nologin
useradd -g nofiles -d /var/qmail qmaill -s /sbin/nologin
useradd -g nofiles -d /var/qmail qmailp -s /sbin/nologin
useradd -g nofiles -d /var/qmail/alias alias -s /sbin/nologin
groupadd qmail
useradd -g qmail -d /var/qmail qmailq -s /sbin/nologin
useradd -g qmail -d /var/qmail qmailr -s /sbin/nologin
useradd -g qmail -d /var/qmail qmails -s /sbin/nologin
./install_spamcontrol.sh
make setup check
./config-fast xxxx.com

vpopmail

http://sourceforge.net/projects/vpopmail/

groupadd vchkpw;useradd vpopmail
CREATE DATABASE vpopmail;
GRANT select,insert,update,delete,create,drop ON vpopmail.* TO vpopmailuser@localhost IDENTIFIED BY ‘vpoppasswd’;
配置(用igenus需要enable-many-domains)
./configure –enable-logging=p
–enable-domain-quotas=y
–enable-auth-module=mysql
–enable-tcprules-prog=/usr/local/bin/tcprules
–enable-tcpserver-file=/etc/tcp.smtp
–disable-mysql-limits
–enable-mysql-logging
–enable-many-domains
make&&make install-strip
vi vpopmail.mysql
vi vlimits.default
echo “xxxx.com” > /home/vpopmail/etc/defaultdomain
vi /home/vpopmail/domains/.quotawarn.msg
From: CAPH Postmaster

Reply-To: postmaster@xxx.com
To: SomeCompany User:;
Subject: Mail quota warning
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

Your mailbox on the server is now more than 90% full.

So that you can continue to receive mail,
you need to remove some messages from your mailbox.

If you require assistance with this,
please contact our support department :

email : postmaster@xxx.com
Tel : 010 68372647
echo “Message rejected. Not enough storage space in user’s mailbox to accept message.” > /home/vpopmail/domains/.over-quota.msg

/var/qmail/rc
vi /var/qmail/rc
#!/bin/sh

# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default

exec env – PATH=”/var/qmail/bin:$PATH”
qmail-start “`cat /var/qmail/control/defaultdelivery`”

echo ./Maildir/ >/var/qmail/control/defaultdelivery
chmod 755 /var/qmail/rc
mkdir /var/log/qmail

/var/qmail/bin/qmailctl

vi /var/qmail/bin/qmailctl
#!/bin/sh

# description: the qmail MTA

PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
LOG_AUTH=1
export LOG_AUTH

QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`

case “$1″ in
start)
echo “Starting qmail”
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo “qmail-send supervise not running”
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo “qmail-smtpd supervise not running”
fi
if svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
else
echo qmail-pop3d supervise not running
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo “Stopping qmail…”
echo ” qmail-smtpd”
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo ” qmail-smtpd”
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo ” qmail-send”
svc -d /service/qmail-send /service/qmail-send/log
echo ” qmail-pop3d”
svc -d /service/qmail-pop3d /service/qmail-pop3d/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/log
qmail-qstat
;;
doqueue|alrm|flush)
echo “Flushing timeout table and sending ALRM signal to qmail-send.”
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo “Sending HUP signal to qmail-send.”
svc -h /service/qmail-send
;;
pause)
echo “Pausing qmail-send”
svc -p /service/qmail-send
echo “Pausing qmail-smtpd”
svc -p /service/qmail-smtpd
echo “Pausing qmail-pop3d”
svc -p /service/qmail-smtpd
echo “Pausing qmail-pop3d”
svc -p /service/qmail-pop3d
;;
cont)
echo “Continuing qmail-send”
svc -c /service/qmail-send
echo “Continuing qmail-smtpd”
svc -c /service/qmail-smtpd
echo “Continuing qmail-pop3d”
svc -c /service/qmail-pop3d
;;
restart)
echo “Restarting qmail:”
echo “* Stopping qmail-smtpd.”
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo “* Sending qmail-send SIGTERM and restarting.”
svc -t /service/qmail-send /service/qmail-send/log
echo “* Restarting qmail-smtpd.”
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
echo “* Restarting qmail-pop3d.”
svc -t /service/qmail-pop3d /service/qmail-pop3d/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
tcprules /etc/tcp.pop3.cdb /etc/tcp.pop3.tmp < /etc/tcp.pop3
chmod 644 /etc/tcp.smtp.cdb
chmod 644 /etc/tcp.pop3.cdb
echo “Reloaded /etc/tcp.smtp.”
echo “Reloaded /etc/tcp.pop3.”
;;
help)
cat < stop — stops mail service (smtp connections refused, nothing goes out)
start — starts mail service (smtp connection accepted, mail can go out)
pause — temporarily stops mail service (connections accepted, nothing leaves)
cont — continues paused mail service
stat — displays status of mail service
cont — continues paused mail service
stat — displays status of mail service
cdb — rebuild the tcpserver cdb file for smtp
restart — stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue — schedules queued messages for immediate delivery
reload — sends qmail-send HUP, rereading locals and virtualdomains
queue — shows status of queue
alrm — same as doqueue
flush — same as doqueue
hup — same as reload
HELP
;;
*)
echo “Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}”
exit 1
;;
esac

exit 0

chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming

supervise 脚本
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log

qmail-send

/var/qmail/supervise/qmail-send/run

#!/bin/sh
exec /var/qmail/rc

/var/qmail/supervise/qmail-send/log/run

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail

qmail-smtpd

/var/qmail/supervise/qmail-smtpd/run

#!/bin/sh

#QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
QMAILDUID=`id -u vpopmail`
QMAILDGID=`id -g vpopmail`

MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo “No /var/qmail/control/rcpthosts!”
echo “Refusing to start SMTP listener because it’ll create an open relay”
exit 1
fi
exec /usr/local/bin/softlimit -m 30000000
/usr/local/bin/tcpserver -v -H -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD”
-u “$QMAILDUID” -g “$QMAILDGID” 0 smtp /usr/local/bin/rblsmtpd -r relays.ordb.org
/var/qmail/bin/qmail-smtpd
/home/vpopmail/bin/vchkpw /bin/true /bin/cmd5checkpw /bin/true 2>&1

/var/qmail/supervise/qmail-smtpd/log/run

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t
/var/log/qmail/smtpd

qmail-pop3d

/var/qmail/supervise/qmail-pop3d/run

#!/bin/sh

LOCAL=`head -1 /var/qmail/control/me`

exec /usr/local/bin/softlimit -m 30000000
/usr/local/bin/tcpserver -x /etc/tcp.pop3.cdb
-H -l $LOCAL
-v -c 20 -R 0 pop3
/var/qmail/bin/qmail-popup $LOCAL
/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1

/var/qmail/supervise/qmail-pop3d/log/run

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t
/var/log/qmail/pop3d

chmod 755 /var/qmail/supervise/qmail-send/run;chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run;chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run;chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
mkdir -p /var/log/qmail/smtpd;chown qmaill /var/log/qmail /var/log/qmail/smtpd
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /var/qmail/supervise/qmail-pop3d /service
touch .qmail-root .qmail-postmaster
ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon
chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster

clamav

http://www.clamav.net/

groupadd clamav
useradd -g clamav -s /sbin/nologin clamav -d /tmp
./configure
make check
make install

maildrop

./configure
make;make install-strip;make install-man

spamassassin

perl Makefile.PL
make
make install
cp spamd/redhat-rc-script.sh /etc/init.d/spamd

qmail-scanner

groupadd qscand;useradd -g qscand -s /sbin/nologin qscand -d /tmp
./configure –spooldir /var/qmailscan –qmaildir /var/qmail –bindir /var/qmail/bin –qmail-queue-binary
/var/qmail/bin/qmail-queue –admin postmaster –domain xxx.com –notify sender,admin –local-domains “xxx.com,xxx.com.cn,xxx.com.cn” –silent-viruses auto –debug yes –unzip 1
–block-password-protected 0 –add-dscr-hdrs 0 –archive 0 –redundant yes –log-details syslog –log-crypto 0
–fix-mime 2 –ignore-eol-check 0 –scanners “clamscan,fast_spamassassin”

cp qmail-scanner-queue.pl /var/qmail/bin
chown qscand:qscand /var/qmail/bin/qmail-scanner-queue.pl
chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl
vi /etc/tcp.smtp

127.:allow,RELAYCLIENT=”",MFDNSCHECK=”",BADMIMETYPE=”",RBLSMTPD=”",QMAILQUEUE=”/var/
qmail/bin/qmail-scanner-queue.pl”

qmailctl cdb
qmailctl restart
contrib/test_installation.sh -doit测试

分类: Mail 标签:

igenus

2006年1月16日 wd 没有评论

igenus需要给vpopmail数据库里添加几个表,同时还需要修改vpopmail表。添加了一个pw_id字段。没有这个这个字段,igenus里面不能修改密码(我就遇到这么一个情况)。

分类: Mail 标签:

qmail中的几个error的产生的原因和解决方法

2006年1月16日 wd 没有评论

deferral: Unable_to_chdir_to_maildir._(#4.2.1)

这个是qmail找不到用户的收信目录所致。如果你是用vpopmail的虚拟域名来管理的,那看看你的control/locals文件,里面不能有虚拟域名,只能有实际域名(这个实际域名的意思应该是使用系统用户作为用户的域,而不是使用vpopmail的虚拟用户的域)。因此呢,如果不是用 vpopmail,那么可能是系统用户的目录权限设置不正确。

如果发生这个错误,首先保证你没有对user/assign做过手动修改,添加域名都是使用vpopmail的vadddomin命令来添加的,没有修改过~vopmail/domins目录以及其下面目录的权限和属主,然后修改了locals文件之后重启应该就没有问题了。

deferral: Uh-oh:_.qmail_has_prog_delivery_but_has_x_bit_set._(#4.7.0)

这个是因为你的.qmail文件设置了x属性,把.qmail文件的x去掉就ok了。这个.qmail文件就在你的domins/xxx.com下面,包括比如.qmail-default之类的文件,修改一下权限,去掉x就ok了。

454 oops, unable to write pipe and I can't auth (#4.3.0)

这个错误是在你打了smtp auth的补丁之后,却发现不能正常auth,输入了正确的用户名密码还是提示不正确。可以通过下面的命令来测试。

[root@caph qmail-smtpd]# telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.
Escape character is '^]'.
220 xxx.com ESMTP
ehlo
250-xxx.com
250-PIPELINING
250-8BITMIME
250-SIZE 104857600
250 AUTH LOGIN PLAIN CRAM-MD5 //显示这个通常表示你已经打好了补丁,不过这个是可以通过修改qmail-smtpd.c文件来定制的。
auth login
334 VXNlcm5hbWU6
awefaq23rasdf
334 UGFzc3dvcmQ6
awefwaef
454 oops, unable to write pipe and I can't auth (#4.3.0)
quit
221 xxx.com
Connection closed by foreign host.

出现了这种问题是因为smtp运行脚本没有设置正确的用户所致。将你的smtp的tcpserver命令的运行用户和组指定一下。

QMAILDUID=`id -u vpopmail`
QMAILDGID=`id -g vpopmail`

/usr/local/bin/tcpserver -v -H -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD”
-u “$QMAILDUID” -g “$QMAILDGID” 0 smtp /usr/local/bin/rblsmtpd -r relays.ordb.org
/var/qmail/bin/qmail-smtpd
/home/vpopmail/bin/vchkpw /bin/true /bin/cmd5checkpw /bin/true 2>&1

不需要修改~vpopmail/bin/vchkpw的属性。

451 qq write error or disk full (#4.3.0)

通常产生这个可能有2个原因:(1)你的qmail queue所在的磁盘空间不足。(2)qmail-scanner-queue的.pl权限设置不正确或者文件有问题。

qq temporary problem (#4.3.0)

看到的都是说不是suidperl就是qmail-scanner-queue.pl的权限设置不对这两个可能。
-rwsr-xr-x 1 qscand qscand 98594 12月 21 10:18 qmail-scanner-queue.pl

vchkpw-smtp: vpopmail user not found

查看/home/vpopmail/bin/vchkpw的属性和smtpd启动的用户名和组有没有问题。

分类: Mail 标签: