命令行发信
root@smtp root]# telnet smtp.sina.com 25
Trying 1Array2.168.1.10...
Connected to smtp.sina.com.
Escape character is ’^]’.
220 dns.sina.com ESMTP Sendmail 8.12.8/8.12.8; Thu, 18 Jan 2007 12:2Array:20 +0800
helo root
250 dns.sina.com Hello pop.yahoo.com [1Array2.168.1.40], pleased to meet you
mail from:root@sina.com (发信人地址)
250 2.1.0 root@sina.com... Sender ok
rcpt to:root@sina.com (收信人地址)
250 2.1.5 root@sina.com... Recipient ok
data (邮件内容)
354 Enter mail, end with "." on a line by itself
Testmailxxxxxx
. (以”.”结束)
250 2.0.0 l0I4TKnT001216 Message accepted for delivery
quit (退出)
221 2.0.0 dns.sina.com closing connection
Connection closed by foreign host.
看一下是否收到信:用mail收信
[root@dns /]# mail (收信)
Mail version 8.1 6/6/Array3. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@sina.com Tue Sep 18 13:53 11/367 (显示有一封信)
& 1 (查看)
Message 1:
From root@sina.com Tue Sep 18 13:53:51 2007
Date: Tue, 18 Sep 2007 13:53:07 +0800
From: root
Hahaha (邮件内容)
& q (退出)
也可以telnet 1Array2.168.1.2 110来收信
[root@rhel-1 ~]# telnet 1Array2.168.1.10 110
Trying 1Array2.168.1.10...
Connected to mail.rhce.com (1Array2.168.1.10).
Escape character is ’^]’.
+OK dovecot ready.
user sina (输入用户名)
+OK
pass 123 (输入密码)
+OK Logged in.
Stat (查看邮件)
+OK 1 8Array3
top 1 8Array3 (查看内容)
+OK
Return-Path:
Received: from server (www.rhce.com [1Array2.168.1.10])
by localhost.localdomain (8.13.1/8.13.1) with SMTP id k8D3TqsT002688
for ; Wed, 13 Sep 2006 11:2Array:52 +0800
Message-ID: 001801c6d6e2$eArray2448a0$0701a8c0@server>
From: "admin"
To:
Subject:
Date: Wed, 13 Sep 2006 11:15:48 +0800
MIME-Version: 1.0
Content-Type: text/plain;
charset="gb2312"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.37Array0.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.37Array0.0
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by localhost.localdomain id k8D3TqsT002688
X-IMAPbase: 1158118231 1
Status: O
X-UID: 1
Content-Length: 13
X-Keywords:
thist a test (邮件内容)
.
Quit (退出)
+OK Logging out.
Connection closed by foreign host.
[root@smtp root]# mail
这时如果可以看到邮件,该MTA就可以正常工作了!
这时MTA1的功能基本实现,但是该服务器只运行了SMTP服务而没有运行POP服务,如果
希望该服务器能够接收用户邮件,需要在本机开启POP服务功能。
[root@localhost cdrom]# rpm -ivh dovecot-0.ArrayArray.11-2.EL4.1.i386.rpm --aid(这些软件都需要安装)
warning: dovecot-0.ArrayArray.11-2.EL4.1.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [ 20%]
2:postgresql-libs ########################################### [ 40%]
3:mysql ########################################### [ 60%]
4:dovecot ########################################### [ 80%]
5:perl-DBD-MySQL ########################################### [100%]
[root@localhost cdrom]# vi /etc/dovecot.conf把14行的修改成下面
14 protocols = imap imaps pop3 pop3s
[root@localhost cdrom]# service dovecot restart
Stopping Dovecot Imap: [ OK ]
Starting Dovecot Imap: [ OK ]
[root@localhost cdrom]# netstat -ntpl | grep 110
tcp 0 0 :::110 :::* LISTEN 2220Array/dovecot
这样MTA1的配置基本完成!
使用同样的方法配置MTA2(邮件服务)??smtp.yahoo.com
所需要修改的文件:
/etc/mail/sendmail.mc 供用户读取的配置文件
/etc/mail/sendmail.cf 供系统读取的配置文件
关系:m4 sendmail.mc > sendmail.cf
/etc/mail/access 邮件转发配置文件
需要:makemap hash access.db
/etc/mail/local-host-names 添加本域FQDN以及邮件服务器的FQDN
/etc/dovecot.conf
完成之后,使用Outlook Express各建立一个使用sina和yahoo的客户端帐号!同时在各自的MTA中建立对应的系统帐号,
通过OE来向对方用户发送邮件成功!
其他配置:(以下在MTA1上进行操作)
配置邮件别名:
[root@dns root]# vi /etc/aliases
这是更改后的内容:
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
sinauser1: sinauser7 ---->发给sinauser1的邮件被sinauser7用户接收(该服务器上存在这两个帐户)
sinauser2: yahoouser1@yahoo.com ---->发给sinauser2的邮件被转发给yahoouser1@yahoo.com(MTA1和MTA2上存在这两个帐户)
sinauser3: sinauser4,sinauser5,sinauser6 ---->发给sinauser3的邮件被sinauser4/5/6接收
配置虚拟别名:
[root@dns mail]# vi virtusertable
这是更改后的内容:
suibian@sina.com sinauser1 ---->发给suibian用户的内容由sinauser1来接收(该服务器上不存在这个帐户)
完成之后: makemap hash virtusertable.db
配置具有SMTP认证功能的sendmail:
查看系统已经安装的认证文件:
[root@dns RPMS]# rpm -qa | grep sasl
cyrus-sasl-md5-2.1.10-4
cyrus-sasl-2.1.10-4
cyrus-sasl-plain-2.1.10-4
cyrus-sasl-gssapi-2.1.10-4
查看目前sendmail支持的认证:[root@dns root]# /usr/sbin/sendmail -d0.1 -bv
Version 8.12.8
Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
NETUNIX NEWDB NIS PIPELINING SASL SCANF STARTTLS TCPWRAPPERS
USERDB USE_LDAP_INIT
============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = dns
(canonical domain name) $j = dns.sina.com
(subdomain name) $m = sina.com
(node name) $k = dns.sina.com
========================================================
Recipient names must be specified
[root@dns mail]# vi /etc/mail/sendmail.mc
修改的内容如下:
将:
dnl # TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)dnl
dnl # define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)dnl
以及后面的:
dnl # DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea’)dnl
更改为:
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)dnl ---->取消注释
define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)dnl ---->取消注释
DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea’)dnl ---->取消注释
FEATURE(`accept_unresolvable_domains’)dnl (接受不能解析的域名邮件,由于我们是在加认证,所以不用对不能解析的域名转发)
把上面这项去掉前面加dnl
完成之后,将/etc/mail/access文件内容全部清空,然后makemap hash access.db
然后使用sasl进行邮件发送认证!
则:
[root@dns mail]# m4 sendmail.mc > sendmail.cf
[root@dns mail]# service sendmail restart
[root@dns mail]# telnet smtp.sina.com 25
Trying 1Array2.168.1.10...
Connected to smtp.sina.com.
Escape character is ’^]’.
220 dns.sina.com ESMTP Sendmail 8.12.8/8.12.8; Thu, 18 Jan 2007 17:3Array:30 +0800
ehlo localhost
250-dns.sina.com Hello dns.sina.com [1Array2.168.1.10], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN ----->认证功能已经支持!
250-DELIVERBY
250 HELP
在邮件客户端中操作:设置用户使用邮件服务器时,勾选“我的邮件服务器需要认证”即可!
在这种情况下,用户发送的邮件都需要SMTP服务器的认证才可进行转发!
其它配置文件详解:
/etc/mail/access :可以阻止一些主机和用户发来的邮件,但要通过makemap hash /etc/mail/access 生成数据库文件
文件左边是写入的用户名,主机的ip地址,域等,右边是针对这个用户名,主机的ip地址,域等做出的行为.
OK 忽略其它设置的权限,完全接收邮件和转发
RELAY 允许转发邮件
REJECT 拒绝接收邮件,并返回错误提示
DISCARD 放弃接收邮件,并不返回错误提示
501 若发信人的地址与指定的user@host部分或完全匹配,不接收邮件
502 若发信人的地址不含有主机名,不接收邮件
503 对指定的域名,不接受邮件
例:
@sina.com OK 转发接收一切sina.com域的用户邮件
1Array2.168.1.10 REJECT 主机1Array2.168.1.10发来的邮件拒绝接收和转发
sina@sina.com
501 messages don’t find
[email=拒绝sina@sina.com]拒绝sina@sina.com[/email]
的邮件,并返回信息
from:sina.com 拒绝从此域发来的邮件
to:sina.com 拒绝到此域的邮件
/etc/mail/relay-domains 和 /etc/mail/access的作用相同
/etc/mail/aliases :用户别名,如果你想把发给几个用户的邮件都发到一个用户那里,或是发给一个用户的邮件同时发给几个用户,可以在这里设置
# vi /etc/mail/aliases
User1:test
User2:test
Test:user1,user2
# newaliases (修改完aliases必须执行newaliases命令)
这样就把所有发给user1和user2的邮件发给了test用户,把发给test的邮件也同时发给了user1,user2
/etc/mail/local-host-names 邮件服务器对哪个域服务
windows下:
在php.ini中配置相应的sendmail路径。[mail function]
; For Win32 only.
SMTP = smtp.163.com
smtp_port = 25
; For Win32 only.
sendmail_from = aa@163.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path ="D:/SendMail/sendmail.exe -t -i"
这样配置后就可以直接使用PHP自带的mail()函数来发送邮件了。
sendmail For win32下载地址:http://www.glob.com.au/sendmail/
源码下载:http://www.sendmail.org/
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。