linux系统下邮件服务器sendmail的配置

2020-01-30 11:32:10王振洲

mail -s 'title text' test@example.com 把文档中内容邮寄出去。
mail -f ~/mbox                        查看home目录下邮箱内容。
用mail发附件也是可行,要用到uuencode and uudecode命令进行编码。
编码:uuencode [file] name          example:uuencode hello hello>;hello.uue   default input
is stdin;default output is stdout.
解码:uudecode [-o outfile] name    example:uudecode hello.uue 能够用-o选项输出另外一个
文档名。
# uuencode ~/.bashrc bashrc | mail -s 'test uuencode'
test@example.com
五、其他配置。
要想更好的使用sendmail,常用到的一些配置:
1、限制最大邮件。
vi /etc/sendmail.cf
# maximum message size
O MaxMessageSize=5000000    (注:5M)
2、最大的群发数目。
vi /etc/sendmail.cf
# maximum number of recipients per SMTP envelope
O MaxRecipientsPerMessage=20  (注:20个)
3、域名文档----local-host-name
能够用他来实现虚拟域名或多域名支持。
/etc/mail/local-host-name
v1mail.com
v2mail.com
.......
4、mail别名文档--aliases。
vi /etc/aliases
系统内部别名:peng:zpeng,hero,mmmn,yt   peng是我的用户名,其他的是别名,用逗号隔开。
转发到其他的邮箱:peng:zpeng@sina.com,yt.sohu.com
#newaliases   --写到库中
5、邮件控制文档--access
relay、ok、reject和discard。relay能够实现转发。ok是用来允许用户的任意访问,他会覆盖任何其他已建立的检查(实际配置中,最好别设这项,除非您对该用户是绝对信任的);reject能够实现对来访地址的拒绝,他根本就不容许该地址和您的邮件服务器进行连接通信;discard的作用是在接收到传输的邮件消息后,偷偷地把他丢弃掉(在发送者看来,他的邮件的确是接收了,但他并不知道,发送的目的地址根本不可能接收到他的邮件,服务器巧妙地欺骗了他。
vi /etc/mail/access.
localhost.localdomain    RELAY      ---允许
localhost                        RELAY
127.0.0.1                       RELAY
peng@sina.com              ok
@sexgirl.net                   reject
211.77.22.45                  discard
#makemap hash access.db 写入库中
6、虚拟用户文档---virtusertable.
这个文档能够mail重名问题。
例如:您有两个域名,virt1.com and virt2.com,但是都有peng这个用户: