Alan Hou的个人博客

PowerMTA相关配置

 
PowerMTA相关配置

PowerMTA的配置文件为/etc/pmta/config,对配置文件进行过修改后需重启PMTA服务(即执行/etc/init.d/pmta restart命令)

1.smtp账户创建
以下为固定格式用户名和密码可自行修改

<smtp-user alan>
        password alanhou
        source {smtpuser-auth}
</smtp-user>
<source {smtpuser-auth}>
        smtp-service yes
        always-allow-relaying yes
        require-auth true
        process-x-virtual-mta yes
        remove-received-headers true
        add-received-header false
        hide-message-source true
</source>

2.host-name设置
接收邮件邮件头中出现,默认显示IP,修改为域名显示更为友好
host-name mail.alanhou.org

3.http-mgmt-port设置
默认web端访问端口是8080,可以进行自定修改,如8000
http-mgmt-port 8000

3.smtp-port设置
smtp默认端口号是25,可以进行自定修改,如2525
smtp-port 2525
可通过netstat -lnpt命令进行查看

4.http-access授权配置
有monitor,none,admin三种权限级别,其中0/0代表所有IP
http-access 0/0 monitor
http-access 10.1.0.10 none
http-access 10.1.0/24 admin

5.Source配置
通过修改如下代码中的0/0来配置限制仅信任的客户端IP来进行访问

<source 127.0.0.1>
    always-allow-relaying yes   # allow feeding from 127.0.0.1
    process-x-virtual-mta yes   # allow selection of a virtual MTA
    max-message-size 0          # 0 implies no cap, in bytes
    smtp-service yes            # allow SMTP service
</source>

<source 0/0>                 # matches all
    log-connections no
    log-commands    no       # WARNING: verbose!
    log-data        no       # WARNING: even more verbose!
</source>

6.domain配置
配置对指定发送域名的相关设置

<domain yahoo.com>
max-smtp-out 50
max-msg-per-connection 5
max-msg-rate 100/h
smtp-greeting-timeout 5m # added in v3.2r17
mx-connection-attempts 10 # added in v3.2r16
smtp-pattern-list backoff
# backoff-to-normal-after 2h #added in v3.5
# backoff-max-msg-per-hour 600 # Use with PowerMTA 3.2
# backoff-max-msg-rate 600/h # Use with PowerMTA 3.5
# backoff-retry-after 30m
# backoff-notify postmaster@yourdomain.com
</domain>

7.vmta配置
对发信域名和IP进行配置,尤其是针对多IP和多域名的配置,以下域名和IP需要进行域名A记录的配置,以下代码中的mail是可以进行自定义

<virtual-mta mail>
smtp-source-host 107.191.61.102    e.alanhou.org
domain-key alanhou,*,/etc/pmta/dkim/alanhou.pem
</virtual-mta>

8.vmta-pool配置
进行虚拟MTA池的设置,例如有两个MTA,mail(即上述代码中自定义名称mail)和test

<virtual-mta-pool alanhou.org>
  virtual-mta mail
  virtual-mta test
</virtual-mta-pool>

9.acct-file配置
日志文件存放配置

<acct-file /var/log/pmta/acct.csv>
#    move-to /opt/myapp/pmta-acct   # configure as fit for your application
    move-interval 5m
    max-size 15M
</acct-file>

Bounce的处理

Bounce通常分为hard bounce和soft bounce
后台修改:
Settings > Email Delivery > Bounces > Monitoring Method(POP3/IMAP Connection)
填写创建的用户名密码
用户名密码创建方法,登录服务器
useradd bounce -s /sbin/nologin
passwd bounce
添加cron job
* * * * * curl -s http://*.*.*.*/oem/cli/web_send.php > /dev/null 2>&1
* * * * * curl -s http://*.*.*.*/oem/cli/web_sync.php > /dev/null 2>&1
* * * * * curl -s http://*.*.*.*/oem/cli/web_transactional_send.php > /dev/null 2>&1
* * * * * curl -s http://*.*.*.*/oem/cli/web_general.php > /dev/null 2>&1
* * * * * curl -s http://*.*.*.*/oem/cli/pop3_bounce.php > /dev/null
* * * * * curl -s http://*.*.*.*/oem/cli/pop3_fbl.php > /dev/null
* * * * * curl -s http://*.*.*.*/oem/cli/pop3_requests.php > /dev/null
其中*.*.*.*代表本机IP,添加cron job可通过crontab -e,查看用crontab -l,添加完成后要进行重启/etc/init.d/crond restart

QQ邮箱发送策略

max-msg-rate 500/h
<domain qq.com>
max-msg-rate 100/h
smtp-pattern-list backoff
</domain>
<smtp-pattern-list backoff>
#视频4分50秒
... .
reply /550 Access denied/ mode=backoff
... ...
</smtp-pattern-list>

gmail,yahoo,hotmail,aol邮箱发送策略

<domain gmail.com>
max-smtp-out 50
max-msg-per-connection 20
max-rcpt-per-message 100
max-msg-rate 250/h
smtp-pattern-list backoff #normal
... ...
</domain>
<domain aol.com>
max-smtp-out 50
max-msg-per-connection 20
max-rcpt-per-message 100
max-msg-rate 1500/h
smtp-pattern-list backoff #normal
... ...
</domain>
<domain yahoo.com>
max-smtp-out 50
max-msg-per-connection 5
max-msg-rate 2000/h
smtp-greeting-attempts 5m
mx-connection-attempts 10
smtp-pattern-list backoff #normal
... ...
</domain>
<domain hotmail.com>
max-smtp-out 50
max-msg-per-connection 5
max-msg-rate 2000/h
421-means-mx-unavailable yes
smtp-pattern-list backoff #normal
... ...
</domain>
退出移动版