iT邦幫忙

0

sendmail與postfix的maillog混在一起? 寄信間隔過長,該如何除錯與縮短時間?

情況:
在Linux用PHP執行 mail()去寄信,發現執行mail()很久,大概需要等待10秒,才會執行下一行程式,查看maillog也覺得很奇怪,sendmail、postfix為何會混在一起使用,但信確實都有收到,所以想請教怎麼檢查標題中的兩個問題?

  1. sendmail、postfix如何混在一起使用?
  2. PHP程式執行mail(),寄信間隔很久(約10秒),該如何除錯與縮短時間?

底下是我執行程式,連續寄兩封信的maillog,如果還需提供什麼資訊,請再回覆我,謝謝。

(第一封信)
Dec 23 09:08:09 localhost sendmail[32082]: 0BN97xJ4032082: from=webrt, size=249, class=0, nrcpts=1, msgid=<202012230907.0BN97xJ4032082@localhost.localdomain>, relay=webrt@localhost
Dec 23 09:08:09 localhost postfix/smtpd[32145]: connect from localhost[127.0.0.1]
Dec 23 09:08:09 localhost postfix/smtpd[32145]: 31FB71F8A81: client=localhost[127.0.0.1]
Dec 23 09:08:09 localhost postfix/cleanup[32148]: 31FB71F8A81: message-id=<202012230907.0BN97xJ4032082@localhost.localdomain>
Dec 23 09:08:09 localhost postfix/qmgr[32017]: 31FB71F8A81: from=<webrt@localhost.localdomain>, size=698, nrcpt=1 (queue active)
Dec 23 09:08:09 localhost sendmail[32082]: 0BN97xJ4032082: to=Eric@abc.com, ctladdr=webrt (1500/1500), delay=00:00:10, xdelay=00:00:00, mailer=relay, pri=30249, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 31FB71F8A81)
Dec 23 09:08:09 localhost postfix/smtpd[32145]: disconnect from localhost[127.0.0.1]
Dec 23 09:08:09 localhost postfix/smtp[32149]: warning: database /etc/postfix/generic.db is older than source file /etc/postfix/generic
Dec 23 09:08:09 localhost postfix/smtp[32149]: 31FB71F8A81: to=<Eric@abc.com>, relay=example.abc.com[0.0.0.0]:25, delay=0.37, delays=0.05/0.01/0.22/0.09, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 78A0C13C095)
Dec 23 09:08:09 localhost postfix/qmgr[32017]: 31FB71F8A81: removed

(第二封信)
Dec 23 09:08:19 localhost sendmail[32150]: 0BN989ol032150: from=webrt, size=249, class=0, nrcpts=1, msgid=<202012230908.0BN989ol032150@localhost.localdomain>, relay=webrt@localhost
Dec 23 09:08:19 localhost postfix/smtpd[32145]: connect from localhost[127.0.0.1]
Dec 23 09:08:19 localhost postfix/smtpd[32145]: 564251F8A81: client=localhost[127.0.0.1]
Dec 23 09:08:19 localhost postfix/cleanup[32148]: 564251F8A81: message-id=<202012230908.0BN989ol032150@localhost.localdomain>
Dec 23 09:08:19 localhost postfix/qmgr[32017]: 564251F8A81: from=<webrt@localhost.localdomain>, size=698, nrcpt=1 (queue active)
Dec 23 09:08:19 localhost sendmail[32150]: 0BN989ol032150: to=Eric@abc.com, ctladdr=webrt (1500/1500), delay=00:00:10, xdelay=00:00:00, mailer=relay, pri=30249, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 564251F8A81)
Dec 23 09:08:19 localhost postfix/smtpd[32145]: disconnect from localhost[127.0.0.1]
Dec 23 09:08:19 localhost postfix/smtp[32149]: 564251F8A81: to=<Eric@abc.com>, relay=example.abc.com[0.0.0.0]:25, delay=0.39, delays=0.04/0/0.23/0.12, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 9E1BD3809C)
Dec 23 09:08:19 localhost postfix/qmgr[32017]: 564251F8A81: removed

補充sendmail、postfix的狀態:

# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-12-23 09:07:48 UTC; 30min ago
  Process: 17049 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
  Process: 31943 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  Process: 31939 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 31933 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
 Main PID: 32015 (master)
   CGroup: /system.slice/postfix.service
           ├─32015 /usr/libexec/postfix/master -w
           ├─32016 pickup -l -t unix -u
           └─32017 qmgr -l -t unix -u
           
# systemctl status sendmail
● sendmail.service - Sendmail Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/sendmail.service; disabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2020-12-23 09:07:48 UTC; 32min ago
  Process: 17066 ExecStart=/usr/sbin/sendmail -bd $SENDMAIL_OPTS $SENDMAIL_OPTARG (code=exited, status=0/SUCCESS)
  Process: 17052 ExecStartPre=/etc/mail/make aliases (code=exited, status=0/SUCCESS)
  Process: 17050 ExecStartPre=/etc/mail/make (code=exited, status=0/SUCCESS)
 Main PID: 17070 (code=exited, status=0/SUCCESS)

2020-12-28補充:
我把sendmail remove,重新測試寄信(只用postfix),發現時間不會出現延遲,但沒有成功收到信,maillog如下

Dec 28 13:06:43 localhost postfix/pickup[1766]: 002953D3FF: uid=0 from=<root>
Dec 28 13:06:43 localhost postfix/cleanup[13115]: 002953D3FF: message-id=<20201228130643.002953D3FF@localdomain.localdomain>
Dec 28 13:06:43 localhost postfix/qmgr[975]: 002953D3FF: from=<root@localdomain.localdomain>, size=466, nrcpt=1 (queue active)
Dec 28 13:06:43 localhost postfix/smtp[13117]: 002953D3FF: to=<eric@abc.com>, relay=abc.com[10.36.6.81]:25, delay=0.46, delays=0/0/0.33/0.13, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 5854C3806E)
Dec 28 13:06:43 localhost postfix/qmgr[975]: 002953D3FF: removed

2021-01-06:
問題已解決,移除Sendmail,只留Postfix去提供寄信功能,就不會有寄信延遲問題。
另一問題,無法收到信件的問題是我使用的relay server拒絕幫我寄信,原因是信中sender的mail address無效,所以我在/etc/potfix/generic最後一行加入

@abc.com eric@example.com

example要使用有效的domain就可以正常收信了,
謝謝。

msnman iT邦研究生 1 級 ‧ 2020-12-24 13:50:05 檢舉
把sendmail服務關閉,再觀察maillog的情況。

尚未有邦友回答

立即登入回答