如何使用[email protected]而不是[email protected]向他人发送电子邮件?

如何使用[email protected]而不是[email protected]向他人发送电子邮件?

我在 noxp.rocks 上构建了 postfix,其 Ip 是 xxx.xxx.xxx.xxx。
使用以下命令登录 vps 并发送电子邮件。

echo "why localhost" |mail -s "test for email address"  [email protected] 

登录我的gmail,我发现电子邮件地址不是[email protected],而是 [email protected]

postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
local_recipient_maps =
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydomain = noxp.rocks
myhostname = mail.noxp.rocks
mynetworks = 127.0.0.0/8
myorigin = $mydomain
mydestination = $myhostname,$mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550

我的 Gmail 中的原始数据。

Delivered-To: [email protected]
Received: by 10.12.155.155 with SMTP id o27csp1259029qve;
        Thu, 5 Oct 2017 20:07:22 -0700 (PDT)
X-Google-Smtp-Source: AOwi7QCm9y+JDqqUapTV1nMIS+p3SeQbqCjXZfB7tO7TqvHOwafeuCeicbmKQBP8Bqhgtx9SFQni
X-Received: by 10.84.232.129 with SMTP id i1mr690079plk.104.1507259242269;
        Thu, 05 Oct 2017 20:07:22 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1507259242; cv=none;
        d=google.com; s=arc-20160816;
        b=AhCXZtOra/BEcPajwZ+sEzZKcHCAbazK4aOYnZ00ogzaAPe6Lqocrbud37iKEZvi1r
         IEUDcSjIv0x9FDMj0qM0QMJ6WusYYOoaKg8xKGJ8LWLDwgfT3p+y3j+iD+ZS2Q/oCcW/
         Fe9Hh4xHdoqO557xVgkcYd2i4ZNyRPjcadxh54dLTf9vBhqfV+dpQSD4+uvULgrSrc7+
         6LL8SnV+bIWb+bZpF63yK4LwFWsbj7Qiu/J8sn8Owx0QhnV/ICjR1ijfI0hfoF/CcLq7
         4P5k7Sc8pliQdJhYkEa0ToNM2/UXNIq23WpT3gvxCaau4DsbaL2eKj9EPR9BbnkdPgKW
         wDdg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:user-agent:subject:to:date
         :message-id:from:arc-authentication-results;
        bh=MQwz2obBjkDDbZ+YWmNfr24yCsXfE0n7NKeCCLuz+l4=;
        b=x2c6z+n8u9ocnP3hjsmRXc7evZ2e0aKLYV4hrQyYGxMfk7pj5WlTm+qyRDdyHBMkfS
         QIjZepfPk0SVE7yPOO/MSCVTzw3f2gvvie52dCzjEAQvReFbm9ILdpUHx3fqrR7x3cNY
         PFN0SL7nStJ6ZBk9yAJsBUQZCGWabRyW/1f3DaLSmROAXb5yiyqd7G7YyiwWacQBJLww
         +/BKh80oocHT7LqNUV9+XxFv6XJAJoLMlvK8GiHyTBYbGqC1hUgOz1YmYuUfT1q7qrfM
         9fBKbsn2gC9SqfIlUatf+Rf6ddMe7Dm7BJs1/Yqy5yj3/7bZvVGAQYlZ005qsYugyOYN
         fLmg==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: xxx.xxx.xxx.xxx is neither permitted nor denied by best guess record for domain of [email protected]) [email protected]
Return-Path: <[email protected]>
Received: from mail.noxp.rocks (noxp.rocks. [xxx.xxx.xxx.xxx])
        by mx.google.com with ESMTP id n1si345687pge.398.2017.10.05.20.07.22
        for <[email protected]>;
        Thu, 05 Oct 2017 20:07:22 -0700 (PDT)
Received-SPF: neutral (google.com: xxx.xxx.xxx.xxx is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=xxx.xxx.xxx.xxx;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: xxx.xxx.xxx.xxx is neither permitted nor denied by best guess record for domain of [email protected]) [email protected]
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.noxp.rocks (Postfix) with ESMTP id 65F5338AAEF2 for <[email protected]>; Thu,
  5 Oct 2017 23:07:20 -0400 (EDT)
Received: (from root@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id v9637K0Z001903 for [email protected]; Thu, 5 Oct 2017 23:07:20 -0400
From: root <[email protected]>
Message-Id: <[email protected]>
Date: Thu, 05 Oct 2017 23:07:20 -0400
To: [email protected]
Subject: test for email address
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

why localhost

还有必要发布其他配置文件吗?
我的配置有什么问题吗?

答案1

hostnamectl  set-hostname  mydomain-name

答案2

使用此命令获取服务器的 FQDN 名称:

hostname -f

输出必须与您的主邮件域相同。或者喜欢mail.your-domain.tld

第二件事:

使用telnetutil从其他主机连接到您的服务器来测试邮件发送:

# telnet smtp.gmail.com 25
Trying 64.233.165.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 smtp.gmail.com ESMTP c26sm201830ljb.12 - gsmtp
EHLO mail.bxxxt.com
250-smtp.gmail.com at your service, [178.162.xx.xx]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8

请注意:

220 smtp.gmail.com ESMTP c26sm201830ljb.12 - gsmtp

有些服务器会检查您的服务器发送的 HELLO。

相关内容