РЕДАКТИРОВАТЬ: Эта проблема разрешилась так же загадочно, как и началась. Я просто надеюсь, что в будущем он снова не появится.
У меня есть небольшой python скрипт, который раз в день отправляет комиксы c на несколько адресов электронной почты. Недавно один человек из моего списка сказал мне, что изображения больше не отображаются. Я получил источник электронного письма из ее учетной записи Gmail, и по какой-то причине раздел изображения в кодировке Base-64 для изображения пустым.
Я понятия не имею, почему это происходит, и почему это происходит только с одним человек. Я получил программный сбой SPF в заголовках Gmail, но я сомневаюсь, что это является причиной этого (это должно произойти со всеми пользователями Gmail в моем списке). Я даже не знаю, что Google может начать устранять эту проблему.
Неправильный источник электронной почты {цензурированные элементы в фигурных скобках}:
Delivered-To: {recipient}@gmail.com
Received: by 2002:ac2:555e:0:0:0:0:0 with SMTP id l30csp2647742lfk;
Sun, 22 Mar 2020 02:12:09 -0700 (PDT)
X-Google-Smtp-Source: ADFU+vt1SopHnbnPh0tuHjbA/v3RMASeIKMyk35ZdIXqQHBr2LmtG11vVo6cI8XXxUf/emCJQjqb
X-Received: by 2002:a92:25d6:: with SMTP id l205mr14876228ill.35.1584868329096;
Sun, 22 Mar 2020 02:12:09 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1584868329; cv=none;
d=google.com; s=arc-20160816;
b=o1VVDgxlMMWGRPy041qJS6LfA1LWjEB6+cbp768sLmMaOk7Q+qbCpAg0Mydf3pg/yu
N3Nfh0Zv7vUdS6sapH0LzmcCG6YVBC/fkGboFuUeVJgVw24CcY8e1ofkMmIkWardIQie
bNfAnebSMmIhmZ6UTrR79ggRhUglFx6EdAzNYdmpyRCxewK3/SN5JjdfW6KUQsgjQXU5
PvJQEZZrt07eKjzq2kpNVobWBj8rOvVGpYc+fqNDOircTIF5ZTI3JIbCEkNvvEyAmZOW
AK68xVtSpaYfInnJ0++dPkS9DhuH777f/yMz6Z0X26MjnoxiIovyYSNPfzZLdjpnC/CI
G4nQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
h=date:message-id:to:from:subject:mime-version;
bh=nXPNVg7/Z2G2UDLCbHAibUHl0oCh4sJ6yhHsm9HpP+Y=;
b=Vl5At9J4nLzeREzg93sHypB2XO/vbNHAtRj4apOzQZHLg0XbjD3Hxv6t9+yzFn8thS
pFnPRPCOOgyY+mp+8hTQrT5TaIlEcNC9Ay1x25X27wqcr0iBjw9xpTvjvFo1pX7jNK7E
DvUZpdSoSmas32U0zT8DH1+jX5zX/8Ydr7aTOkVLPX6umVuyl2RNlW+mLZrPnCMkiH0Z
jeTc88LMiczwsVwo2qsoKPDjFah+xTD7J+zqnuHr6IuMS3+s9t7dy4sbKRwlcxP4n2z4
ZXjJbQpEEfOec36EF89By4ZHNHxLmDx/DZvPA5nv10emet1Omki9w2HF3hcaAijZDL2l
jb1g==
ARC-Authentication-Results: i=1; mx.google.com;
spf=softfail (google.com: domain of transitioning {sender}@{my-domain} does not designate {my-ip-address} as permitted sender) smtp.mailfrom={sender}@{my-domain}
Return-Path: <{sender}@{my-domain}>
Received: from {my-domain} ([{my-ip-address}])
by mx.google.com with ESMTP id 141si8443110ile.78.2020.03.22.02.12.03
for <{recipient}@gmail.com>;
Sun, 22 Mar 2020 02:12:09 -0700 (PDT)
Received-SPF: softfail (google.com: domain of transitioning {sender}@{my-domain} does not designate {my-ip-address} as permitted sender) client-ip={my-ip-address};
Authentication-Results: mx.google.com;
spf=softfail (google.com: domain of transitioning {sender}@{my-domain} does not designate {my-ip-address} as permitted sender) smtp.mailfrom={sender}@{my-domain}
Received: from {my-domain} (localhost [IPv6:::1]) by {my-domain} (Postfix) with SMTP id BEFC13C00DD for <{recipient}@gmail.com>; Sun, 22 Mar 2020 05:12:02 -0400 (EDT)
Content-Type: multipart/related; boundary="===============0513549325=="
MIME-Version: 1.0
Subject: Calvin and Hobbes of the day
From: {sender}@{my-domain}
To: {recipient}@gmail.com
Message-Id: <20200322091202.BEFC13C00DD@{my-domain}>
Date: Sun, 22 Mar 2020 05:12:02 -0400 (EDT)
--===============0513549325==
Content-Type: multipart/alternative; boundary="===============1139914447=="
MIME-Version: 1.0
--===============1139914447==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Calvin and Hobbes of the day email. Image not displayed for techical reasons. To unsubscribe, send an email to {sender}@{my-domain} with the subject "Unsubscribe please". You may briefly continue to recieve emails until the system processes your request.
--===============1139914447==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
<img src="cid:30cbc076bf26fa38547141665a3874fc0bdc91b550d5b9523fbf033cd64d0d8b"><p>This Calvin and Hobbes was originally published on Tuesday, March 22, 1994. Enjoy!</p><p style="font-family:serif;text-size:9pt;">To unsubscribe, send an email to <a href="mailto:{sender}@{my-domain}?subject=Unsubscribe please">{sender}@{my-domain}</a> with the subject "Unsubscribe please". You may briefly continue to recieve emails until the system processes your request.</p>
--===============1139914447==--
--===============0513549325==
Content-Type: image/gif
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-ID: <30cbc076bf26fa38547141665a3874fc0bdc91b550d5b9523fbf033cd64d0d8b>
--===============0513549325==--
Пример электронного письма, которое отображается правильно (также отправлено на учетную запись Gmail):
Delivered-To: {recipient2}@gmail.com
Received: by 2002:ac0:945c:0:0:0:0:0 with SMTP id j28csp4283482imj;
Sun, 22 Mar 2020 02:12:06 -0700 (PDT)
X-Google-Smtp-Source: ADFU+vsBj6iMIZiI5aEUI+EaVIoyR/pGQUdx46SNDNiosv8OoI8WLTCvAYmWxdVSsUEGEThEY3kc
X-Received: by 2002:a92:4090:: with SMTP id d16mr1882262ill.200.1584868326631;
Sun, 22 Mar 2020 02:12:06 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1584868326; cv=none;
d=google.com; s=arc-20160816;
b=o85d2nyxnlrJBxjPjbEIK+iBEUzip5+8qaw3AP2sf1oWPSHGUjyKSJMM9ya0nTgByo
wn+hN60zGz/y23w7k6yp3V0gy94rP+qiMRn87bgahsdF6SOH6n2gDn1aYPFNZPCLRrgU
UI+a3aX/qdDtw03LL8A9mj+v+TCvEyntddxWjiU2UHuXT88GLOPAwmt0PwH/wQp52nRV
V4jnKFbGQU7A2FkzJccW1T6GgzoXejmXOcHi4z7emm4TGHNv4FxlPl/bna2X8dFo+8N5
mHh7+ADWyy9wHATPJqPEtTXuBoE8Bri9n20IMKaPWKzpoasb5bFV14kA+cRkh/CckHr7
3Vxw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
h=date:message-id:to:from:subject:mime-version;
bh=tcCxyEZafImccO+owloPVRqzcCuM+m7me+VxZuISjGU=;
b=e5DjPTX5Ia11uM7bKBRA+vGqkGlsYdJuv6Mxio7xhRtcxqBxxxyIZ80ludnCvWR/j8
/B1qmGG6ZynxVlv7GTPOF4yP6qWhE2sycKf3yQ5MYZXLFmZMRSW0kcj/fjoKvd3BOOBV
8DlZUNVvfNujZpm+7sdNHhT+xAU8EY1+9+b3R6GDEyDJzKrIgXclX9yVHsH91DDa5AC8
WOUBH4ZrOZ0Zn5bvpSLOomqhGI4J2gZeb41zj8RjjuwPOE9LR5fmDCxNn+ajeBAbnJPG
Ihl3jkrnuiJWcigsn38ctPw6inWglsK3dxKBTeXbrWHHeRtu9kHZnL1l9vpl93BM/LN9
6jgQ==
ARC-Authentication-Results: i=1; mx.google.com;
spf=softfail (google.com: domain of transitioning {sender}@{my-domain} does not designate {my-ip-address} as permitted sender) smtp.mailfrom={sender}@{my-domain}
Return-Path: <{sender}@{my-domain}>
Received: from {my-domain} ([{my-ip-address}])
by mx.google.com with ESMTP id k2si9367254jap.23.2020.03.22.02.12.03
for <{recipient2}@gmail.com>;
Sun, 22 Mar 2020 02:12:06 -0700 (PDT)
Received-SPF: softfail (google.com: domain of transitioning {sender}@{my-domain} does not designate {my-ip-address} as permitted sender) client-ip={my-ip-address};
Authentication-Results: mx.google.com;
spf=softfail (google.com: domain of transitioning {sender}@{my-domain} does not designate {my-ip-address} as permitted sender) smtp.mailfrom={sender}@{my-domain}
Received: from {my-domain} (localhost [IPv6:::1])
by {my-domain} (Postfix) with SMTP id 98FA73C00A7
for <{recipient2}@gmail.com>; Sun, 22 Mar 2020 05:12:02 -0400 (EDT)
Content-Type: multipart/related; boundary="===============1535165371=="
MIME-Version: 1.0
Subject: Calvin and Hobbes of the day
From: {sender}@{my-domain}
To: {recipient2}@gmail.com
Message-Id: <20200322091202.98FA73C00A7@{my-domain}>
Date: Sun, 22 Mar 2020 05:12:02 -0400 (EDT)
This is a multi-part message in MIME format.
--===============1535165371==
Content-Type: multipart/alternative; boundary="===============1545014324=="
MIME-Version: 1.0
--===============1545014324==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Calvin and Hobbes of the day email. Image not displayed for techical reasons. To unsubscribe, send an email to {sender}@{my-domain} with the subject "Unsubscribe please". You may briefly continue to recieve emails until the system processes your request.
--===============1545014324==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
<img src="cid:30cbc076bf26fa38547141665a3874fc0bdc91b550d5b9523fbf033cd64d0d8b"><p>This Calvin and Hobbes was originally published on Tuesday, March 22, 1994. Enjoy!</p><p style="font-family:serif;text-size:9pt;">To unsubscribe, send an email to <a href="mailto:{sender}@{my-domain}?subject=Unsubscribe please">{sender}@{my-domain}</a> with the subject "Unsubscribe please". You may briefly continue to recieve emails until the system processes your request.</p>
--===============1545014324==--
--===============1535165371==
Content-Type: image/gif
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-ID: <30cbc076bf26fa38547141665a3874fc0bdc91b550d5b9523fbf033cd64d0d8b>
R0lGODlhhAMgAfcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4O
Dg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEh
ISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0
NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdH
R0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpa
WltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1t
{ ... snipped 1462 lines worth of base-64 encoded data ... }
/pQ29JRRfUNJrQ5VOZVPzEP3CAxVzcM3zIPr2EdJ6dRKDoxUvcND5NIWCVEsBQYYmRMg4UUuKYT9
1FBCrKQ9+MVKGsTwHERX8eRCzEMrVsM3kMMmGhUmro7jxKRBXOU8SFVM8sS4eFA2+eRZomVKBGVK
vMMuRMIglFFatoZUAVEVHMIp9MKzpANRLoQ2DEI3yWVgCuZgEmZhGuZhIuZPRgREDEwS+eRaJmZi
yos5HeUS2ZBjHmWWJBHkJMYObWb8gCYPsc9oro/6EIxN3JD8mM5okiZjFsxicqbpyJBpwolpztBr
OiZqglFWVIVr/lBqpib4uI9uug9nMmZmFuf7dqCmcp6mD2Hmc+oGpwjnZ7LJEhlnD9XmDkXOcl5m
Y/LQb87mdopnbBIRDdlQZaqmdmYndlqQUjind8KncH6nq1SnD6GnbuJnfq5lZVIJZEZmJu1mpKhl
bhLoSrhmbZxTgf7ngjJoutBngy6mbCbFFPknhA5mQAAAOw==
--===============1535165371==--
РЕДАКТИРОВАТЬ: Некоторые из моих других получателей также сообщили, что это происходило в прошлом, но это продолжалось всего день или два, и они не особо задумывались об этом. (Я полагаю, что все они также пользователи Gmail ...)
РЕДАКТИРОВАТЬ: Вот несколько урезанная версия кода, который отправляет электронные письма. В этом же каталоге находится файл address.py, в котором есть вложенный массив со всеми адресами электронной почты в моем списке.
#!/usr/bin/python
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
import hashlib
import os
import datetime
from addresses import arrayTo # Addresses to send to
# Note: Calvin and Hobbes ran from 1985-11-18 to 1995-12-31
today = datetime.datetime.now()
comicDay = datetime.datetime(((today.year - 6) % 10 + 1990), today.month, today.day)
dateString = str(comicDay.year) + '-' + str(comicDay.month) + '-' + str(comicDay.day)
# Some definitions
for n in range(0,len(arrayTo)):
strTo = ''
numAddresses = len(arrayTo[n])
for i in range(0,numAddresses): # Concatenate address array into CSV
strTo += arrayTo[n][i]
if i < numAddresses - 1: # Don't end with a comma
strTo += ', '
strFrom = '{sender}@{my-domain}'
comicFile = '/path/to/files/picture_' + dateString + '.png'
if os.path.exists(comicFile):
# Open the image, assuming the image is in the current directory
fp = open(comicFile, 'rb')
msgImage = MIMEImage(fp.read())
fp.close()
# Generate a hash to use as the CID
comicHash = hashlib.sha256(comicFile).hexdigest()
# Create the root message and fill in the from, to, and subject headers
msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = 'Calvin and Hobbes of the day'
msgRoot['From'] = strFrom
msgRoot['To'] = strTo
msgRoot.preamble = 'This is a multi-part message in MIME format.'
# Encapsulate the plain and HTML versions of the message body in an
# 'alternative' part, so message agents can decide which they want to display.
msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)
msgText = MIMEText('Calvin and Hobbes of the day email. Image not displayed for techical reasons. To unsubscribe, send an email to {sender}@{my-domain} with the subject "Unsubscribe please". You may briefly continue to recieve emails until the system processes your request.')
msgAlternative.attach(msgText)
# We reference the image in the IMG SRC attribute by the ID we chose above
msgText = MIMEText('<img src="cid:' + comicHash + '"><p>This Calvin and Hobbes was originally published on ' + comicDay.strftime('%A, %B %d, %Y') + '. Enjoy!</p><p style="font-family:serif;text-size:9pt;">To unsubscribe, send an email to <a href="mailto:{sender}@{my-domain}?subject=Unsubscribe please">{sender}@{my-domain}</a> with the subject "Unsubscribe please". You may briefly continue to recieve emails until the system processes your request.</p>', 'html')
msgAlternative.attach(msgText)
# Define the image's ID as referenced above
msgImage.add_header('Content-ID', '<' + comicHash + '>')
msgRoot.attach(msgImage)
# Send the email
import smtplib
smtpObj = smtplib.SMTP('localhost', 25)
smtpObj.helo()
smtpStatus = smtpObj.sendmail(strFrom, arrayTo[n], msgRoot.as_string())
smtpObj.quit()
if (smtpStatus != {}):
# code to log this error
else:
# code to log this error