尽管修改了 /etc/aliases,仍通过 [email protected] 发送电子邮件

尽管修改了 /etc/aliases,仍通过 [email protected] 发送电子邮件

首先,这是我添加/修改的条目/etc/postfix/main.cf文件:

mydomain = domain.com
myorigin = $mydomain
relayhost = email-smtp.us-east-1.amazonaws.com:25
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/amazon-ses
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
header_checks = regexp:/etc/postfix/header_checks

现在,如果我像这样发送测试邮件......

$ sudo sendmail [email protected]
To: [email protected]
From: [email protected]
Subject: Test email!
This is just a test email.
.

并检查邮件日志(/var/log/mail.log),我看到这个:

Feb 17 04:23:16 hostname postfix/pickup[6226]: B3DD4137ED: uid=0 from=<root>
Feb 17 04:23:16 hostname postfix/cleanup[6230]: B3DD4137ED: replace: header From: [email protected] from local; from=<[email protected]> to=<[email protected]>: From: "WebsiteName Alerts (no reply)" <[email protected]>
Feb 17 04:23:16 hostname postfix/cleanup[6230]: B3DD4137ED: message-id=<[email protected]>
Feb 17 04:23:16 hostname postfix/qmgr[6144]: B3DD4137ED: from=<[email protected]>, size=353, nrcpt=1 (queue active)
Feb 17 04:23:18 hostname postfix/smtp[6232]: B3DD4137ED: to=<[email protected]>, relay=email-smtp.us-east-1.amazonaws.com[107.22.250.234]:25, delay=25, delays=24/0.03/0.93/0.58, dsn=2.0.0, status=sent (250 Ok 0000013ce6644ae6-69927d25-c4e1-4f25-8ad4-b85b59318e84-000000)
Feb 17 04:23:18 hostname postfix/qmgr[6144]: B3DD4137ED: removed

正如您所看到的,日志显示了[email protected][email protected]as,from尽管我在命令[email protected]中特别指出了sendmail

尽管修改了我的/etc/别名像这样的文件:

# /etc/aliases
mailer-daemon: [email protected]
postmaster: [email protected]
nobody: [email protected]
hostmaster: [email protected]
usenet: [email protected]
news: [email protected]
webmaster: [email protected]
www: [email protected]
ftp: [email protected]
abuse: [email protected]
noc: [email protected]
security: [email protected]
root: [email protected]

那么,问题是,如何[email protected]为系统设置默认电子邮件地址?换句话说,如何将 root 用户的电子邮件地址从 更改[email protected][email protected]

如果这很重要,我的系统运行的是 Debian 7 (Wheezy) 64 位。

答案1

除了用户名与域名组合之外,没有默认的返回电子邮件地址。当您使用 sudo 调用 sendmail 时,它会使用root用户名来创建信封返回地址。要更改此行为,请使用-f带有 sendmail 的开关:

   -fname Sets the name of the ``from'' person (i.e., the envelope  sender
          of the mail).  This address may also be used in the From: header
          if that header is missing during initial submission.  The  enve‐
          lope sender address is used as the recipient for delivery status
          notifications and may also appear in a Return-Path: header.   -f
          should only be used by ``trusted'' users (normally root, daemon,
          and network) or if the person you are trying to  become  is  the
          same  as  the  person  you are.  Otherwise, an X-Authentication-
          Warning header will be added to the message.

相关内容