postfix的安装过程非常容易!
参考以下安装步骤:
安装碰到问题?
这是最简单的安装,都是使用的默认配置,默认是使用系统账户才能发送邮件的。
需要发送邮件,是需要启动服务的,如果是sendmail,那就需要启动sendmail,这里是postfix,会取代sendmail,并且兼容sendmail。
启动postfix:
直接用系统的mail命令发送邮件看看:
看看收到的邮件的原始信息(相应的信息有修改):
为什么是root@localhost.localdomain呢,因为postfix启动时会取hostname,系统账户发送邮件会用此hostname,如果你已经正常设置了,那就是你设置的hostname,我们可以定义自己的:
我们发送同样的邮件,收到的邮件是:
你可以用php来发送邮件,比如php例子里的:
我们看看邮件是怎么样的:
明显,from参数是可以定制的,这个很好,这个很合适用来作为php的邮件发送处理程序。
我们可以切换用户来做这个:
看看我们收到的邮件:
用户不同了,那就有所不一样哦,初次体验完毕!
原创内容如转载请注明:来自 阿权的书房
参考以下安装步骤:
wget http://www.postfix.cn/source/official/postfix-2.6.5.tar.gz
tar xfz postfix-2.6.5.tar.gz
cd postfix-2.6.5
useradd postfix -M -s /sbin/nologin
groupadd postdrop
make
make install
tar xfz postfix-2.6.5.tar.gz
cd postfix-2.6.5
useradd postfix -M -s /sbin/nologin
groupadd postdrop
make
make install
安装碰到问题?
引用
> No include file found.
> Install the appropriate db*-devel package first.
可以用yum更新,17M左右:
yum -y install db*-devel
> Install the appropriate db*-devel package first.
可以用yum更新,17M左右:
yum -y install db*-devel
这是最简单的安装,都是使用的默认配置,默认是使用系统账户才能发送邮件的。
需要发送邮件,是需要启动服务的,如果是sendmail,那就需要启动sendmail,这里是postfix,会取代sendmail,并且兼容sendmail。
启动postfix:
postfix start
直接用系统的mail命令发送邮件看看:
[root@localhost postfix-2.6.5]# mail your-email@gmail.com
Subject: test postfix
test
.
Cc:
Subject: test postfix
test
.
Cc:
看看收到的邮件的原始信息(相应的信息有修改):
引用
Delivered-To: your-email@gmail.com
Received: by 10.115.58.13 with SMTP id l13cs26345wak;
Sun, 3 Jan 2010 05:13:02 -0800 (PST)
Received: by 10.142.249.24 with SMTP id w24mr6307016wfh.254.1262524382509;
Sun, 03 Jan 2010 05:13:02 -0800 (PST)
Return-Path:
Received: from localhost.localdomain ([218.241.1.2])
by mx.google.com with ESMTP id 14si52469845pwi.38.2010.01.03.05.13.02;
Sun, 03 Jan 2010 05:13:02 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@localhost.localdomain) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@localhost.localdomain) smtp.mail=root@localhost.localdomain
Received: by localhost.localdomain (Postfix, from userid 0)
id 25BA9B6EAA; Wed, 18 Nov 2009 12:15:10 +0800 (CST)
To: your-email@gmail.com
Subject: test postfix
Message-Id: <20091118041510.25BA9B6EAA@localhost.localdomain>
Date: Wed, 18 Nov 2009 12:15:10 +0800 (CST)
From: root@localhost.localdomain (root)
test
Received: by 10.115.58.13 with SMTP id l13cs26345wak;
Sun, 3 Jan 2010 05:13:02 -0800 (PST)
Received: by 10.142.249.24 with SMTP id w24mr6307016wfh.254.1262524382509;
Sun, 03 Jan 2010 05:13:02 -0800 (PST)
Return-Path:
Received: from localhost.localdomain ([218.241.1.2])
by mx.google.com with ESMTP id 14si52469845pwi.38.2010.01.03.05.13.02;
Sun, 03 Jan 2010 05:13:02 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@localhost.localdomain) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@localhost.localdomain) smtp.mail=root@localhost.localdomain
Received: by localhost.localdomain (Postfix, from userid 0)
id 25BA9B6EAA; Wed, 18 Nov 2009 12:15:10 +0800 (CST)
To: your-email@gmail.com
Subject: test postfix
Message-Id: <20091118041510.25BA9B6EAA@localhost.localdomain>
Date: Wed, 18 Nov 2009 12:15:10 +0800 (CST)
From: root@localhost.localdomain (root)
test
为什么是root@localhost.localdomain呢,因为postfix启动时会取hostname,系统账户发送邮件会用此hostname,如果你已经正常设置了,那就是你设置的hostname,我们可以定义自己的:
postconf -e "myhostname=aslibra.com"
postfix reload
postfix reload
我们发送同样的邮件,收到的邮件是:
引用
Delivered-To: your-email@gmail.com
Received: by 10.115.58.13 with SMTP id l13cs26653wak;
Sun, 3 Jan 2010 05:22:54 -0800 (PST)
Received: by 10.142.3.13 with SMTP id 13mr3309463wfc.302.1262524974528;
Sun, 03 Jan 2010 05:22:54 -0800 (PST)
Return-Path:
Received: from aslibra.com ([218.241.1.2])
by mx.google.com with ESMTP id 2si24602186pxi.52.2010.01.03.05.22.53;
Sun, 03 Jan 2010 05:22:53 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) smtp.mail=root@aslibra.com
Received: by aslibra.com (Postfix, from userid 0)
id 725D1B6EAA; Wed, 18 Nov 2009 12:20:43 +0800 (CST)
To: your-email@gmail.com
Subject: test after hostname
Message-Id: <20091118042043.725D1B6EAA@aslibra.com>
Date: Wed, 18 Nov 2009 12:20:43 +0800 (CST)
From: root@aslibra.com (root)
test
Received: by 10.115.58.13 with SMTP id l13cs26653wak;
Sun, 3 Jan 2010 05:22:54 -0800 (PST)
Received: by 10.142.3.13 with SMTP id 13mr3309463wfc.302.1262524974528;
Sun, 03 Jan 2010 05:22:54 -0800 (PST)
Return-Path:
Received: from aslibra.com ([218.241.1.2])
by mx.google.com with ESMTP id 2si24602186pxi.52.2010.01.03.05.22.53;
Sun, 03 Jan 2010 05:22:53 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) smtp.mail=root@aslibra.com
Received: by aslibra.com (Postfix, from userid 0)
id 725D1B6EAA; Wed, 18 Nov 2009 12:20:43 +0800 (CST)
To: your-email@gmail.com
Subject: test after hostname
Message-Id: <20091118042043.725D1B6EAA@aslibra.com>
Date: Wed, 18 Nov 2009 12:20:43 +0800 (CST)
From: root@aslibra.com (root)
test
你可以用php来发送邮件,比如php例子里的:
[root@aslibra webapps]# cat mail.php
<?php
$to = 'your-email@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
[root@aslibra webapps]# php mail.php
<?php
$to = 'your-email@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
[root@aslibra webapps]# php mail.php
我们看看邮件是怎么样的:
引用
Delivered-To: your-email@gmail.com
Received: by 10.115.58.13 with SMTP id l13cs26361wak;
Sun, 3 Jan 2010 05:13:30 -0800 (PST)
Received: by 10.114.23.5 with SMTP id 5mr739493waw.41.1262524410287;
Sun, 03 Jan 2010 05:13:30 -0800 (PST)
Return-Path:
Received: from aslibra.com ([218.241.1.2])
by mx.google.com with ESMTP id 2si24598106pxi.18.2010.01.03.05.13.29;
Sun, 03 Jan 2010 05:13:30 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) smtp.mail=root@aslibra.com
Received: by aslibra.com (Postfix, from userid 0)
id 1C521B6EAA; Wed, 18 Nov 2009 12:15:27 +0800 (CST)
To: your-email@gmail.com
Subject: the subject
From: webmaster@example.com
Reply-To: webmaster@example.com
X-Mailer: PHP/5.1.6
Message-Id: <20091118041527.1C521B6EAA@aslibra.com>
Date: Wed, 18 Nov 2009 12:15:27 +0800 (CST)
hello
Received: by 10.115.58.13 with SMTP id l13cs26361wak;
Sun, 3 Jan 2010 05:13:30 -0800 (PST)
Received: by 10.114.23.5 with SMTP id 5mr739493waw.41.1262524410287;
Sun, 03 Jan 2010 05:13:30 -0800 (PST)
Return-Path:
Received: from aslibra.com ([218.241.1.2])
by mx.google.com with ESMTP id 2si24598106pxi.18.2010.01.03.05.13.29;
Sun, 03 Jan 2010 05:13:30 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of root@aslibra.com) smtp.mail=root@aslibra.com
Received: by aslibra.com (Postfix, from userid 0)
id 1C521B6EAA; Wed, 18 Nov 2009 12:15:27 +0800 (CST)
To: your-email@gmail.com
Subject: the subject
From: webmaster@example.com
Reply-To: webmaster@example.com
X-Mailer: PHP/5.1.6
Message-Id: <20091118041527.1C521B6EAA@aslibra.com>
Date: Wed, 18 Nov 2009 12:15:27 +0800 (CST)
hello
明显,from参数是可以定制的,这个很好,这个很合适用来作为php的邮件发送处理程序。
我们可以切换用户来做这个:
[root@aslibra webapps]# su www
[www@aslibra webapps]$ php mail.php
[www@aslibra webapps]$ php mail.php
看看我们收到的邮件:
引用
Delivered-To: your-email@gmail.com
Received: by 10.115.58.13 with SMTP id l13cs26932wak;
Sun, 3 Jan 2010 05:35:12 -0800 (PST)
Received: by 10.141.23.12 with SMTP id a12mr15722236rvj.158.1262525711961;
Sun, 03 Jan 2010 05:35:11 -0800 (PST)
Return-Path:
Received: from aslibra.com ([218.241.1.2])
by mx.google.com with ESMTP id 10si24608922pxi.75.2010.01.03.05.35.10;
Sun, 03 Jan 2010 05:35:11 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of www@aslibra.com) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of www@aslibra.com) smtp.mail=www@aslibra.com
Received: by aslibra.com (Postfix, from userid 501)
id E1674B6EAA; Wed, 18 Nov 2009 12:27:34 +0800 (CST)
To: your-email@gmail.com
Subject: the subject
From: webmaster@example.com
Reply-To: webmaster@example.com
X-Mailer: PHP/5.1.6
Message-Id: <20091118042734.E1674B6EAA@aslibra.com>
Date: Wed, 18 Nov 2009 12:27:34 +0800 (CST)
hello
Received: by 10.115.58.13 with SMTP id l13cs26932wak;
Sun, 3 Jan 2010 05:35:12 -0800 (PST)
Received: by 10.141.23.12 with SMTP id a12mr15722236rvj.158.1262525711961;
Sun, 03 Jan 2010 05:35:11 -0800 (PST)
Return-Path:
Received: from aslibra.com ([218.241.1.2])
by mx.google.com with ESMTP id 10si24608922pxi.75.2010.01.03.05.35.10;
Sun, 03 Jan 2010 05:35:11 -0800 (PST)
Received-SPF: neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of www@aslibra.com) client-ip=218.241.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 218.241.1.2 is neither permitted nor denied by best guess record for domain of www@aslibra.com) smtp.mail=www@aslibra.com
Received: by aslibra.com (Postfix, from userid 501)
id E1674B6EAA; Wed, 18 Nov 2009 12:27:34 +0800 (CST)
To: your-email@gmail.com
Subject: the subject
From: webmaster@example.com
Reply-To: webmaster@example.com
X-Mailer: PHP/5.1.6
Message-Id: <20091118042734.E1674B6EAA@aslibra.com>
Date: Wed, 18 Nov 2009 12:27:34 +0800 (CST)
hello
用户不同了,那就有所不一样哦,初次体验完毕!
原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
初识Postfix和extmail
北京-大雪天

怎么查看是什么原因呢?
麻烦有回复通知一下impunk@gmail.com
非常感谢!