Debian

從我的伺服器發送狀態通知(延遲)電子郵件?

  • April 17, 2019

我正在使用 Debian Jessie 伺服器並設置了 exim4來向我發送電子郵件,而不是 postfix 或 sendmail。

那是我開始收到大量電子郵件的時候,如下所示:

第一的:

標題:*** vultr.guest 的安全資訊 ***

正文:vultr.guest:12 月 7 日 12:13:29:root:無法解析主機 vultr.guest

第二:

標題:cron test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp

身體:

This is an automatically generated Delivery Status Notification

THIS IS A WARNING MESSAGE ONLY.

YOU DO NOT NEED TO RESEND YOUR MESSAGE.

Delivery to the following recipient has been delayed:

     root@example.com

Message will be retried for 2 more day(s)

Technical details of temporary failure:
The recipient server did not accept our requests to connect. Learn more at https://support.google.com/mail/answer/7720
[(10) example.com. [xxx.xxx.xxx.90]:25: socket error]

----- Original message -----

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=from:to:subject:mime-version:content-type:content-transfer-encoding
         :message-id:date;
        bh=k/8GlT8DBvBIJzBOOfw8qR0kGPzj7m9ZR/aj+JOKBhg=;
        b=eA6kpVtS0eNBO0CFBfLzlnaYwZ9/GubMaWTGUkG4MaxbNy55YxY2jZAuh3RHI2mo8Q
         qp5OmKihchYTgCxcAx0xvJaXuuxDhoT9dCJ6YEIzqjmypWjpUEqoXkNu7uKU4Cd1vTfS
         5/dSvE7zVE6TYe4L18vrOiYBEUNrJQ3lTdv//RrlHZs/f62GorIyMHgVL4XvkVNLWF/K
         lK9SSybf9ee3KTKUxurBm1Tyah62Gk4/869Hynr1QEAjSAzM8sSKDyKH/KOZ06sDWtPQ
         jE0Agxffk8RkhsFkEtIbpZBfS/zagGZ8+CXsGqR9541ylMAHGOGeYtRp4oiB8tVP2Sbv
         h4Rw==
X-Received: by 10.129.114.10 with SMTP id n10mr3081975ywc.0.1449600002717;
        Tue, 08 Dec 2015 10:40:02 -0800 (PST)
Return-Path: <myEmailAddress@gmail.com>
Received: from vultr.guest ([104.156.246.90])
        by smtp.gmail.com with ESMTPSA id f203sm2998216ywf.45.2015.12.08.10.40.02
        for <root@example.com>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 08 Dec 2015 10:40:02 -0800 (PST)
From: Cron Daemon <myEmailAddress@gmail.com>
X-Google-Original-From: root@example.com (Cron Daemon)
Received: from smmsp by vultr.guest with local (Exim 4.84)
        (envelope-from <smmsp@example.com>)
        id 1a6NBB-0007Vu-Os
        for root@example.com; Tue, 08 Dec 2015 13:40:01 -0500
To: root@example.com
Subject: Cron <smmsp@vultr> test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/var/lib/sendmail>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=smmsp>
Message-Id: <E1a6NBB-0007Vu-Os@vultr.guest>
Date: Tue, 08 Dec 2015 13:40:01 -0500

我編輯/etc/cron.d/sendmail並首先嘗試將MAILTO=行從更改root為我的 gmail 地址。那沒有幫助。所以我評論了那條線,然後

*/20 *    *    *    *       smmsp   test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp

這使它不再每 20 分鐘向我發送一次帶有垃圾郵件的電子郵件。但我仍然收到很多而且經常與

主題:*** vultr.guest 的安全資訊 * 正文** :

This is an automatically generated Delivery Status Notification

THIS IS A WARNING MESSAGE ONLY.

YOU DO NOT NEED TO RESEND YOUR MESSAGE.

Delivery to the following recipient has been delayed:

    root@example.com

Message will be retried for 1 more day(s)

Technical details of temporary failure:
The recipient server did not accept our requests to connect. Learn more at https://support.google.com/mail/answer/7720
[(10) example.com. [xxx.xxx.xxx.90]:25: socket error]

我確實修改/etc/hostname並刪除vultr.guest並替換為example.com. 而/etc/hosts我只有:

127.0.0.1   localhost
127.0.1.1   install.install install

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我配置錯了什麼?我該如何解決?

更新:/etc/exim4/update-exim4.conf.conf內容是:

dc_eximconfig_configtype='satellite'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

在我看來,VULTR 的教程是不正確的。當您配置 exim4 bydpkg-reconfigure exim4-config時,他們告訴您選擇mail sent by smarthost; no local mail,並配置如下:

System mail name: YOUR_HOSTNAME
IP-addresses to listen on for incoming SMTP connections: 127.0.0.1 ; ::1
Other destinations for which mail is accepted: <BLANK>
Visible domain name for local users: <BLANK>
IP address or host name of the outgoing smarthost: smtp.gmail.com::587
Keep number of DNS-queries minimal (Dial-on-Demand)? No
Split configuration into small files? No
Root and postmaster mail recipient: <BLANK>

但我懷疑Other destinations for which mail is accepted:應該是BLANK. 如果您配置它,請添加您的電子郵件地址或您的example.com域/電子郵件。

否則,請嘗試編輯以下位置:

/etc/別名

root: address@example.com
mailer-daemon: address@example.com
postmaster: address@example.com
nobody: address@example.com
hostmaster: address@example.com
usenet: address@example.com
news: address@example.com
webmaster: address@example.com
www: address@example.com
www-data: address@example.com
ftp: address@example.com
abuse: address@example.com
noc: address@example.com
security: address@example.com
*: address@example.com

並編輯/etc/email-addresses以包含使用者:電子郵件組合:

root: address@example.com
mail: address2@example2.com
*: address@example.com

然後重新啟動 service sendmail restartservice exim4 restart

引用自:https://unix.stackexchange.com/questions/248575