| Profil de PhillipZ.F.BlogListes | Aide |
|
03/07/2008 PostfixBasicSetupHowtoIntroductionThis document will teach you how to set up a basic Postfix mail server with IMAP and POP3 services. It does not included advanced topics such as integrating virus-checking and spam-filtering, which are dealt with in PostfixVirtualMailBoxClamSmtpHowto and PostfixCompleteVirtualMailSystemHowto.
Setup OverviewIn our setup, Postfix sends and receives mail from Internet and stores them in the user mailboxes while clients in the Internet can retrieve their mails via Courier IMAP or POP3. The user authentication is done by Courier Authdaemon. The following diagram shows this process. Anatomy of Postfix
ComponentsThe Following figure shows the main Postfix system components, and the main information flows between them. Receiving MailWhen a message enters the Postfix mail system, the first stop on the inside is the incoming queue. The figure below shows the main components that are involved with new mail. Mail is posted locally. The Postfix sendmail program invokes the privileged postdrop program which deposits the message into the maildrop directory, where the message is picked up by the pickup daemon. This daemon does some sanity checks, in order to protect the rest of the Postfix system. Mail comes in via the network. The Postfix SMTP server receives the message and does some sanity checks, in order to protect the rest of the Postfix system. Mail is generated internally by the Postfix system itself, in order to return undeliverable mail to the sender. The bounce or defer daemon brings the bad news. Mail is forwarded by the local delivery agent, either via an entry in the system-wide alias database, or via an entry in a per-user .forward file. This is indicated with the unlabeled arrow. Mail is generated internally by the Postfix system itself, in order to notify the postmaster of a problem (this path is also indicated with the unlabeled arrow).The Postfix system can be configured to notify the postmaster of SMTP protocol problems, UCE policy violations, and so on. The cleanup daemon implements the final processing stage for new mail. It adds missing From: and other message headers, arranges for address rewriting to the standard user@fully.qualified.domain form, and optionally extracts recipient addresses from message headers. The cleanup daemon inserts the result as a single queue file into the incoming queue, and notifies the queue manager of the arrival of new mail. The cleanup daemon can be configured to transform addresses on the basis of canonical and virtua table lookups. On request by the cleanup daemon, the trivial-rewrite daemon rewrites addresses to the standard user@fully.qualified.domain form.
In this setup I assume that your domain is yourdomain.com and it has a valid MX record call mail.yourdomain.com. Remember to replace yourdomain.com with your actual domain in the example codes in this howto. Also I assume that you know what an MX record is. To find out MX your type in a terminal:
To install postfix
Intall mailx package for use as command mail utility program. Mail command is installed with this package.
Add a user before you start this.
Test your default installation using the following code segment.
Postfix will prompt like following in the terminal so that you can use to type SMTP commands.
Type the following code segment in Postfix's prompt.
Check the mailbox of fmaster
When you type mail command an output like follows display in your terminal.
You will observe that mails are indexed by numbers and you can type the number of which the mail that you want to read. For example type no "2" to read the 2nd mail. The type "q" to quit. The mail will be written to a file called mbox in user's home directory. According to our example it will be /home/fmaster/mbox.
All messages in an mbox type of mailbox are concatenated and stored in a single file. The beginning of each message is indicated by a line whose first five characters are "From " and a blank line is appended to the end of each message
Maildir is a format for an e-mail spool that does not require file locking to maintain message integrity because the messages are kept in separate files with unique names. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur. The subdirectories should all reside on the same filesystem.
Another reason to use Maildir format is that Courier IMAP/POP3 servers only work with Maildir format of mailboxes.
Please find out more about Maildir here
Instruct Postfix to use Maildirs instead of Mboxes:
Ensure Procmail isn't used: (if the step was taken during dpkg-reconfigure, by mistake)
Restart Postfix to make changes effect.
Test your setup again
Add your domains to mydestination:
Add your local networks, too:
Postfix comes with the localhost (127.0.0.1) entry; you may have others, here we assume your LAN is on 192.168.1.0/24. Make changes to suit your situation.
Make Postfix to receive mail from the Internet
Instruct Postfix to receive on all interfaces:
(optional) Make Postfix accept IPv4, IPv6 protocols
If you're not using IPv6 yet, and you're paranoid, use "ipv4" instead of "all". Again, this is to suit your own network sensibilities.
Finally, restart Postfix;
Test your setup again using following code:
Check the mailbox of fmaster
Now you will see mail has a separate file.
Type in a terminal:
Use the following example code segment for your test. Be intelligent to tweak the changes appropriately to your environment. An output like follows will display in your terminal.
Type the following code segment in the prompt provided by the Courier POP3 server. I assume that you are intelligent enough not to type the lines which starts from +OK
Type in a terminal:
Use the following example code segment for your test. Be intelligent to tweak the changes appropriately to your environment. An output like follows will display in your terminal.
Type the following code segment in the prompt provided by the Courier IMAP server.
When mail is to be delivered locally, the local delivery agent runs each local recipient name through the aliases database. The mapping does not affect addresses in message headers. Local aliases are typically used to implement distribution lists, or to direct mail for standard aliases such as postmaster to real people. The table can also be used to map Firstname.Lastname addresses to login names.
Alias lookups are enabled by default and you will see following code segment in main.cf file.
The following codes illustrate how you can setup an alias. This step is optional since we are going to configure virtual mail domains later in this howto. I have added this step to make understand how you can do this in case of a requirement.
Create a user
Edit the alias table
Open the alias file with:
Add the following code:
To make your changes effect type:
To test your changes send a mail to fmaster and check the mail in /home/sysadmin/Maildir/new folder.
Users can control their own mail delivery by specifying destinations in a file called .forward in their home directories. The syntax of these files is the same as with system aliases, except that the lookup key and colon are not present.
I will illustrate an example here:
Assume that you need to for all the mails which comes sysadmin account to an another account do like this
Then open the .forward file
Add the following code:
Remember to use email address which exists in this exercise.
Now send a mail to sysadmin and mail should come to fossedu@example.com
With this approach, every hosted domain can have its own info etc. email address. However, it still uses LINUX system accounts for local mailbox deliveries.
With virtual alias domains, each hosted address is aliased to a local UNIX system account or to a remote address. The example below shows how to use this mechanism for the fossedu.org and linuxelabs.com domains.
Inside the main.cf file, we tell it how to handle these virtual domains:
Edit the /etc/postfix/virtual file:
Add two Linux system accounts
Set Password for the above users.
Add the following code segment:
To create a Map Database type : The postmap is utility program that will convert /etc/postfix/virtual to /etc/postfix/virtual.db Berkley DB format, so that Postfix can access the data faster.
Restart Postfix to make changes effect:
Send mails to both info@fossedu.org and info@linuxelabs.com and those mails should come to mailboxes of sigiri and kala respectively. 29/05/2006 C#格式化数值结果表C#格式化数值结果表
StringsThere really isn't any formatting within a strong, beyond it's alignment. Alignment works for any argument being printed in a String.Format call.
NumbersBasic number formatting specifiers:
Custom number formatting:
The group separator is especially useful for formatting currency values which require that negative values be enclosed in parentheses. This currency formatting example at the bottom of this document makes it obvious: DatesNote that date formatting is especially dependant on the system's regional settings; the example strings here are from my local locale.
The 'U' specifier seems broken; that string certainly isn't sortable. Custom date formatting:
Enumerations
Some Useful ExamplesString.Format("{0:$#,##0.00;($#,##0.00);Zero}", value);
String.Format("{0:(###) ###-####}", 18005551212);
13/04/2006 pragma指令简介 (ZT)在编写程序的时候,我们经常要用到#pragma指令来设定编译器的状态或者是指示编译器完成一些特定的动作. 一. message 参数。 message #pragma message(“消息文本”) 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。
#pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) //将函数存放在.my_data1节中 //r1为标识符,将函数放入.my_data2节中 int main() {
这是一个比较常用的指令,只要在头文件的最开始加入这条指令就能够保证头文件被编译一次
BCB可以预编译头文件以加快链接的速度,但如果所有头文件都进行预编译又可能占太多磁盘空间,所以使用这个选项排除一些头文件。
该指令允许有选择性的修改编译器的警告消息的行为
主要用到的警告表示有如下几个: once:只显示一次(警告/错误等)消息 如果大家对上面的解释不是很理解,可以参考一下下面的例子及说明 在这段代码的最后,重新保存所有的警告信息(包括4705,4706和4707) 在使用标准C++进行编程的时候经常会得到很多的警告信息,而这些警告信息都是不必要的提示, 在vc中使用ADO的时候也会得到不必要的警告信息,这个时候我们可以通过
该指令将一个注释记录放入一个对象文件或可执行文件中, compiler:将编译器的版本号和名称放入目标文件中,本条注释记录将被编译器忽略 exestr:将commentstring参数放入目标文件中,在链接的时候这个字符串将被放入到可执行文件中, lib:这是一个非常常用的关键字,用来将一个库文件链接到目标文件中
你可以在程序中设置下列链接选项 /DEFAULTLIB user:将一般的注释信息放入目标文件中commentstring参数包含注释的文本信息,这个注释记录将被链接器忽略
#pragma pack(n) 控制对齐 如 上面所说的#pragma指令并没有包含所有的参数说明,本人只是提供了一些相对来说比较常用的参数,有不当的地方还 #pragma 预处理指令详解(ZT)在所有的预处理指令中,#Pragma 指令可能是最复杂的了,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C ++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义,编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。 其格式一般为: #Pragma Para 其中Para 为参数,下面来看一些常用的参数。 传统的到出 DLL 函数的方法是使用模块定义文件 (.def),Visual C++ 提供了更简洁方便的方法,那就是“__declspec()”关键字后面跟“dllexport”,告诉连接去要导出这个函数,例如: 把“__declspec(dllexport)”放在函数声明的最前面,连接生成的 DLL 就会导出函数“_MyExportFunction@4”。 上面的导出函数的名称也许不是我的希望的,我们希望导出的是原版的“MyExportFunction”。还好,VC 提供了一个预处理指示符“#pragma”来指定连接选项 (不仅仅是这一个功能,还有很多指示功能) ,如下: 这下就天如人愿了:)。如果你想指定导出的顺序,或者只将函数导出为序号,没有 Entryname,这个预处理指示符 (确切地说是连接器) 都能够实现,看看 MSDN 的语法说明: @ordinal 指定顺序;NONAME 指定只将函数导出为序号;DATA 关键字指定导出项为数据项。 05/09/2005 如何通过139端口远程重起NT服务器转至:Shotgun 最近很多朋友问我:NT的机器如果远程管理软件坏了,怎么重起呢? 1、net use \\xxx.xxx.xxx.xxx\ipc$ password /user:username 2、net use H: \\xxx.xxx.xxx.xxx\c$ 3、copy con h:\reboot.bat netstat命令Netstat 显示协议统计和当前的 TCP/IP 网络连接。该命令只有在安装了 TCP/IP 协议后才可以使用。 netstat [-a] [-e] [-n] [-s] [-p protocol] [-r] [interval] 参数 -a 显示所有连接和侦听端口。服务器连接通常不显示。 -e 显示以太网统计。该参数可以与 -s 选项结合使用。 -n 以数字格式显示地址和端口号(而不是尝试查找名称)。 -s 显示每个协议的统计。默认情况下,显示 TCP、UDP、ICMP 和 IP 的统计。-p 选项可以用来指定默认的子集。 -p protocol 显示由 protocol 指定的协议的连接;protocol 可以是 tcp 或 udp。如果与 -s 选项一同使用显示每个协议的统计,protocol 可以是 tcp、udp、icmp 或 ip。 -r 显示路由表的内容。 interval 重新显示所选的统计,在每次显示之间暂停 interval 秒。按 CTRL+B 停止重新显示统计。如果省略该参数,netstat 将打印一次当前的配置信息。 |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|