mail -r选项被忽略

时间:2018-12-23 21:12:09

标签: centos mailx

我正在2台不同的CentOS计算机上运行此命令。一个改变了“从”,就像我期望的那样,另一个没有改变。要解决此问题,我需要看什么以确定我的设置混乱了?

命令:

mail -s "test email" -r fromemail@fake.com -- toemail@fake.com << EOF
test email
EOF

运行的机器:

> lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.7 (Final)
Release:        6.7
Codename:       Final

> sudo yum info postfix
Loaded plugins: changelog, fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: mirror.web-ster.com
 * epel: mirrors.cat.pdx.edu
 * extras: mirror.web-ster.com
 * updates: mirror.web-ster.com
Installed Packages
Name        : postfix
Arch        : x86_64
Epoch       : 2
Version     : 2.6.6
Release     : 6.el6_7.1
Size        : 9.7 M
Repo        : installed
From repo   : updates
Summary     : Postfix Mail Transport Agent
URL         : http://www.postfix.org
License     : IBM
Description : Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL),
            : TLS

Available Packages
Name        : postfix
Arch        : x86_64
Epoch       : 2
Version     : 2.6.6
Release     : 8.el6
Size        : 2.0 M
Repo        : base
Summary     : Postfix Mail Transport Agent
URL         : http://www.postfix.org
License     : IBM
Description : Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL),
            : TLS

无法运行的机器:

> lsb_release -a
LSB Version:    :base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.9 (Final)
Release:        6.9
Codename:       Final
> sudo yum info postfix
Loaded plugins: auto-update-debuginfo, fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: repo1.ash.innoscale.net
 * epel: mirror.math.princeton.edu
 * epel-debuginfo: mirror.math.princeton.edu
 * extras: mirror.atlantic.net
 * rpmforge: mirror.us.leaseweb.net
 * rpmfusion-free-updates: mirror.math.princeton.edu
 * rpmfusion-free-updates-debuginfo: mirror.math.princeton.edu
 * rpmfusion-nonfree-updates: mirror.math.princeton.edu
 * rpmfusion-nonfree-updates-debuginfo: mirror.math.princeton.edu
 * updates: ewr.edge.kernel.org
Installed Packages
Name        : postfix
Arch        : i686
Epoch       : 2
Version     : 2.6.6
Release     : 8.el6
Size        : 9.4 M
Repo        : installed
From repo   : base
Summary     : Postfix Mail Transport Agent
URL         : http://www.postfix.org
License     : IBM
Description : Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL),
            : TLS

现在显然存在一些版本差异,但是为什么新版本的OS或后缀会对此产生影响?同样,在这种情况下,mailx命令(“ mail”是“ mailx”的别名)都是相同的版本。我认为这是一个奇怪的配置问题,只是不知道在哪里查找。

很显然,我不能冒险破坏可以正常运行的计算机,因此我无法更新它,因此所有版本都匹配。

更新: 我做了以下测试,仍然是同样的问题(从电子邮件发送不正确,并且“回复”无效):

echo "Temp test" | mail -s "Test email" -r "fromemail@fromemail.com" -- toemail@toemail.com

sudo grep "Mar 22 13:26" /var/log/maillog
Mar 22 13:26:22 wmsCentOSdev1 postfix/pickup[11260]: 2E00A2844E3: uid=1031 from=<fromemail@fromemail.com>
Mar 22 13:26:22 wmsCentOSdev1 postfix/cleanup[11995]: 2E00A2844E3: message-id=<5c951abd.TB7ek4rlLmuYRH9a%fromemail@fromemail.com>
Mar 22 13:26:22 wmsCentOSdev1 postfix/qmgr[2967]: 2E00A2844E3: from=<fromemail@fromemail.com>, size=467, nrcpt=1 (queue active)
Mar 22 13:26:24 wmsCentOSdev1 postfix/smtp[11997]: 2E00A2844E3: to=<toemail@toemail.com>, relay=smtp.gmail.com[2607:f8b0:4002:c00::6d]:587, delay=2.9, delays=0.26/0.27/0.58/1.7, dsn=2.0.0, status=sent (250 2.0.0 OK  1553275584 205sm3453486ywd.15 - gsmtp)
Mar 22 13:26:24 wmsCentOSdev1 postfix/qmgr[2967]: 2E00A2844E3: removed

不确定这是否重要,但是在正常运行的机器上进行了相同的测试,这是邮件日志,显示“继电器”值有所不同。可能是问题所在吗?

Mar 22 13:41:23 app postfix/pickup[16506]: CBC0469435: uid=1014 from=<fromemail@fromemail.com>
Mar 22 13:41:23 app postfix/cleanup[19431]: CBC0469435: message-id=<5c951e43.usMAOJ1nzo2Bewl5%fromemail@fromemail.com>
Mar 22 13:41:23 app postfix/qmgr[1108]: CBC0469435: from=<fromemail@fromemail.com>, size=458, nrcpt=1 (queue active)
Mar 22 13:42:04 app postfix/smtp[19433]: CBC0469435: to=<toemail@toemail.com>, relay=mail.mobiwms.com[23.229.187.200]:25, delay=41, delays=0.04/0.01/20/21, dsn=2.0.0, status=sent (250 OK id=1h7OBA-00CWCd-8G)
Mar 22 13:42:04 app postfix/qmgr[1108]: CBC0469435: removed

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

好的,问题出在我的后缀设置上。请参见下面的更改(当然main.cf是当前版本):

diff main.cf.20190322 main.cf
119c119
< inet_protocols = all
---
> inet_protocols = ipv4
704,710c704,710
< relayhost = [smtp.gmail.com]:587
< smtp_use_tls = yes
< smtp_sasl_auth_enable = yes
< smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
< smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
< smtp_sasl_security_options = noanonymous
< smtp_sasl_tls_security_options = noanonymous
---
> ##relayhost = [smtp.gmail.com]:587
> ##smtp_use_tls = yes
> ##smtp_sasl_auth_enable = yes
> ##smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
> ##smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
> ##smtp_sasl_security_options = noanonymous
> ##smtp_sasl_tls_security_options = noanonymous

这不是完美的方法(我在邮件日志中看到了Google的退回错误,但电子邮件仍然可以通过),但绝对更好。也许这会帮助别人。