zoukankan      html  css  js  c++  java
  • postfix配置&使用

    myorigin = $mydomain  #以“user@example.com”(而不是“user@hostname.example.com”)发送邮件,
                            #这样就没有理由将邮件发送到“user@hostname.example.com”。
    # 一般使用domain name,而不使用hostname relayhost
    = $mydomain #将所有邮件转发到负责“example.com”域的邮件服务器。 #如果在某些远程目标无法访问时关闭邮件,则可以防止邮件卡在空客户端上。 #如果您的“example.com”域没有MX记录,请在此处指定真实的主机名。
    # The relayhost parameter specifies the default host to send mail to
    # when no entry is matched in the optional transport(5) table. When
    # no relayhost is given, mail is routed directly to the destination.
    # transport table (转发规则表) > relayhost > $mydestination
    inet_interfaces
    = loopback-only #不接受来自网络的邮件。 # The inet_interfaces parameter specifies the network interface # addresses that this mail system receives mail on.指定接受邮件的网卡地址 mynetworks = 127.0.0.0/8 10.0.0.0/24 #指定可信网络。 # The mynetworks parameter specifies the list of "trusted" SMTP clients that have more privileges than "strangers". relay_domains = #此主机不会从不受信任的网络中继邮件。 #The relay_domains parameter restricts what destinations this system will relay mail to.# 指定收件人的域名,也就是允许中继的域名 mydestination = #禁用本地邮件传递。所有邮件都按照第【relay_domains】的说明进入邮件服务器。          # The mydestination parameter specifies the list of domains that this # machine considers itself the final destination for.# 指定本地邮件域

    例子1:

    mydomain = qq.com

    #inet_interfaces = localhost inet_interfaces = all # 所有网卡都接受邮件 mynetworks_style = subnet # 通过子网形式显示信任网络 mynetworks = 168.100.189.0/28, 127.0.0.0/8 # 指定信任网络 #relay_domains = $mydestination relay_domains = #relayhost = [gateway.my.domain] relayhost = [gateway.my.domain]

    例子2:

    mydomain = qq.com
    
    #inet_interfaces = localhost
    inet_interfaces = all
    
    #mynetworks_style = subnet
    
    #mynetworks = 168.100.189.0/28, 127.0.0.0/8
    
    #relay_domains = $mydestination
    relay_domains = qq1.com,qq2.com... # 只允许中继这些域
    
    #relayhost = [gateway.my.domain]
    relayhost = [gateway.my.domain]


    # 强制发送队列中的邮件
    postfix flush
    postqueue -f

    # 查看邮件队列大小
    mailq | wc -l
    postqueue -p |wc -l

    # 查看队列中的邮件
    mailq
    postqueue -p

    # 查看特定邮件内容
    postcat -q Queue_ID

    # 按邮件ID删除队列中的邮件
    postsuper -d Queue_ID

    # 暂缓发送队列中的邮件
    postsuper -h Queue_ID
    postsuper -h ALL deferred
    # 解除暂缓发送
    postsuper -H Queue_ID
    postsuper -H ALL deferred

    # 重新加入队列
    postsuper -r Queue_ID
    postsuper -r ALL

    # 删除队列中的问题邮件
    postsuper -d ALL deferred
    find /var/spool/postfix/deferred -type f -exec rm -vf {} ;

    # 删除3天以内未发出的邮件
    find /var/spool/postfix/deferred -type f -mtime +3 -exec rm -f {} ;

    # 删除超过5天的问题邮件的退信记录
    find /var/spool/postfix/defer -type f -mtime +5 -exec rm -f {} ;

    # 列出所有问题邮件
    find /var/spool/postfix/deferred -type f -exec ls -l --time-style=+%Y-%m-%d_%H:%M:%S {} ;

    # 复杂用法:利用grep得到特定的邮件ID,再删除,如:(待确认????????????????)
    mailq | grep -B 1 "Hotconcerts@gmail.com" | cut -f 1 -d ! > deletionIDs" $ cat deletionIDs | postsuper -d -


    postfix有四种不同的邮件队列,并且由队列管理进程统一进行管理:
      1. maildrop:本地邮件放置在maildrop中,同时也被拷贝到incoming中。
      2. incoming:放置正在到达或队列管理进程尚未发现的邮件。
      3. active:放置队列管理进程已经打开了并正准备投递的邮件,该队列有长度的限制。
      4. deferred:放置不能被投递的邮件。

    ## 常用管理命令
    # 重新读取postfix配置文件
    postfix reload
    # 检查配置
    postfix check

    # 显示配置内容,在mail.cf配置过的
    postconf -n
    # 所有配置内容,包括默认配置内容
    postconf

  • 相关阅读:
    php中curl类常用方法封装和详解
    一个简单的PHP的CURL类
    PHP的curl常用的5个例子
    PHP封装CURL扩展
    马老师的WoTou生产消费线程讲解例子
    URL路径设置----第二章:创建和管理内容
    浅谈js设计模式之迭代器模式
    浅谈js设计模式之代理模式
    浅谈js设计模式之策略模式
    浅谈js设计模式之单例模式
  • 原文地址:https://www.cnblogs.com/goozgk/p/9780155.html
Copyright © 2011-2022 走看看