V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
delavior
V2EX  ›  问与答

跪求 postfix 使用

  •  
  •   delavior · 2015-03-31 19:35:40 +08:00 · 1993 次点击
    这是一个创建于 3327 天前的主题,其中的信息可能已经有所发展或是发生改变。
    背景:基本完全不懂linux,最近在学习zabbix.发信告警功能需要本地邮件服务器.只要发信不需要收信
    经过:网上查了一堆,试了一下午都没有成功,对自己的智商绝望了.
    服务器上postfix本来就是装好的,我就改了一下main.cf文件,下面是我改的地方:

    myhostname=mail.test.com
    mydomain=test.com
    myorigin=$mydomain
    inet_interfaces=all
    mydestination=$mydomain,localhost.$mydomain,localhost,$mydomain
    mynetworks=192.168.0.244,127.0.0.1
    relay_domains=$mydestination

    然后按网上说的测试:telnet localhost 25

    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    220 mail.test.com ESMTP Postfix
    421 4.4.2 mail.test.com Error: timeout exceeded
    Connection closed by foreign host.

    之前还改了一些地方,记不太清了,这是最后的结果,之前的结果是没有倒数第二行和倒数第三行。
    请大家指点一下,是这么设置吗,哪儿出错了

    疑问:如果只发信不收信,只用postfix能实现吗
    而且zabbix添加邮箱时没发现能添加密码,我在想能实现发信的时候直接发不用密码吗

    跪谢啊
    第 1 条附言  ·  2015-04-01 10:51:54 +08:00
    这是执行postconf -n的结果:(有些我没改,可能是行号变了被认为改了)
    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/libexec/postfix
    data_directory = /var/lib/postfix
    debug_peer_level = 2
    home_mailbox = Maildir/
    html_directory = no
    inet_interfaces = all
    inet_protocols = all
    mail_owner = postfix
    mailq_path = /usr/bin/mailq.postfix
    manpage_directory = /usr/share/man
    mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
    mydomain = test.com
    myhostname = mail.test.com
    mynetworks = 192.168.0.244,127.0.0.1
    myorigin = $mydomain
    newaliases_path = /usr/bin/newaliases.postfix
    queue_directory = /var/spool/postfix
    readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
    relay_domains = $mydestination
    sample_directory = /usr/share/doc/postfix-2.6.6/samples
    sendmail_path = /usr/sbin/sendmail.postfix
    setgid_group = postdrop
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain = $myhostname
    smtpd_sasl_security_options = noanonymous
    unknown_local_recipient_reject_code = 550

    其他改的还有/etc/sasl2/smtpd.conf内容:
    #pwcheck_method: saslauthd
    pwcheck_method:auxprop
    mech_list: plain login

    以及/etc/sysconfig/saslauthd内容:
    SOCKETDIR=/var/run/saslauthd
    MECH=shadow
    FLAGS=sasldb

    下面是/var/log/maillog的最后一次试的结果:
    Apr 1 10:28:13 test postfix/postfix-script[7848]: starting the Postfix mail system
    Apr 1 10:28:13 test postfix/master[7849]: daemon started -- version 2.6.6, configuration /etc/postfix
    Apr 1 10:30:18 test postfix/smtpd[8387]: connect from test[127.0.0.1]
    Apr 1 10:35:18 test postfix/smtpd[8387]: timeout after CONNECT from test[127.0.0.1]
    Apr 1 10:35:18 test postfix/smtpd[8387]: disconnect from test[127.0.0.1]
    第 2 条附言  ·  2016-09-25 15:39:41 +08:00
    RTFM
    9 条回复    2015-04-02 09:27:07 +08:00
    kidlj
        1
    kidlj  
       2015-03-31 20:34:10 +08:00   ❤️ 1
    Postfix 默认起来什么都不用改就可以发信了。不信你可以用 `mail -s 'test mail' [email protected]`发一封信试试,不过发信地址是 [email protected]
    delavior
        2
    delavior  
    OP
       2015-03-31 21:41:25 +08:00
    @kidlj 是吗?太感谢了,明天去试试。
    jiayao321
        3
    jiayao321  
       2015-04-01 02:37:50 +08:00 via Android
    为什么一定要用跪求两个字
    sooj8ieT
        4
    sooj8ieT  
       2015-04-01 10:07:28 +08:00
    @jiayao321 以后牛逼起来了,就不会用跪求了。用跪求,要么自卑,要么屌丝。
    delavior
        5
    delavior  
    OP
       2015-04-01 10:56:45 +08:00
    @kidlj 改回默认发信的时候过了几分钟仍然没成功,一直停在那
    kidlj
        6
    kidlj  
       2015-04-01 15:46:57 +08:00   ❤️ 1
    用 mail 写完信以后 CTRT+D 结束,才会发送。
    kidlj
        7
    kidlj  
       2015-04-01 15:47:11 +08:00
    另外注意查收“垃圾邮件”。
    delavior
        8
    delavior  
    OP
       2015-04-01 19:11:24 +08:00
    @kidlj 非常感谢,果然成功了
    delavior
        9
    delavior  
    OP
       2015-04-02 09:27:07 +08:00
    @kidlj 抱歉,再问一个问题,我发送的正文怎么收不到啊.

    [root@test ~]# mail [email protected]
    Subject: test mail 2
    Hello,this is a test mail
    .
    EOT

    上面是发信的命令,结果收到的邮件只有主题,没有正文,试了好几遍都是这样。请问发信的命令不对还是还需要配置别的?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3968 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 00:14 · PVG 08:14 · LAX 17:14 · JFK 20:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.