尝试构建符合RFC3156 [0]的消息,并通过Gmail API发送(我正在使用python客户端实现)。
我得到的是:在我的Gmail框中,邮件已正确发送(我完全看到我之前构建的邮件)·
我的接收者得到的是:“多部分/混合”消息,其中包含与我发送的消息相同的有效负载。
似乎在某些时候,Gmail会更改我的内容类型......这是真的吗?
作为解决方法,我正在使用SMTP连接(其行为与我期望的一样,正确地发送消息),但是在将来我想避免这一步骤支持纯Gmail API应用程序。
你能否确认这个问题?
[0] - 这是一个测试例子:
发送消息:
message_as_str = '''Content-Type: multipart/signed; protocol="application/pgp-signature";\n micalg="pgp-sha512"; boundary="===============0594182808971957567=="\nMIME-Version: 1.0\nDate: Wed, 12 Nov 2014 12:18:02 +0100\nSubject: A test email\nFrom: Leo Iannacone <l3on@ubuntu.com>\nTo: Andrea Colangelo <warp10@ubuntu.com>\n\n--===============0594182808971957567==\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nHello,\r\n\r\nthis is a signed email (RFC 3156).\r\n\r\nBest,\r\nL.\r\n\r\n-- =\r\n\r\nUbuntu Member - http://launchpad.net/~l3on\r\nHome Page - http://leoiannacone.com\r\nGPG Key Id - 0xD282FC25\r\n\n--===============0594182808971957567==\nContent-Type: application/pgp-signature; name="signature.asc"\nContent-Description: GooPG digital signature\n\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABCgAGBQJUY0JcAAoJEDMrlP7SgvwlQakP/jmw6OOcafFAxMnMZNBREnG6\nGF3cG/ACJ6BeYhOb0Q2HFQrUKACbsB8QaTxSCf3q7O0HIl5Atr9IVmVIoUuHOM9M\nZt66LWQ3ZUpvyulBswYOq4ERkeeAZh8AYHCz81SUWt42PDn+RrrKESifkgOgy1cM\nUpNUXX99cppdY3w1oKVS0SFdhT4ZDNSr6PVUzPzWOHNk3OGOg4okTJOag3lp5R1x\nIMQ4plOFNNUs1bDDOpH75TOOGIAdqqgInH5fOk8h2djrPyCozhyllrpCJdiCkrj9\njkL/m0nNS/wHW/pnqSPHZuMDrEYCiiI4fqJYZUkiXQu/koDt40TUqAdeEy1HWJS2\npPqqXjjiZ1jlQ2IBbOG8YfgsLmexTyNE6CmPBXiVk6zY2hnhA6sjq/I9qF8F73SS\nFALfkbdRddN7NMzjFVES3eV2gfrUrQnxru2G8urUeeQ2POQrxsGQvb5CrK7VMaUx\nteB9UruIpPLNUYR0E7Cr17lqlMR5ILdSlx5xFxIIjg3pfItHQXoOfyusoO1xt8XK\ntY8oateT4dgwfR2qrguAnZ96vXtI1soqy8P1TLrJAI/d95kIw4PMzWVm1GjyUiRe\ngPhYqvGQV6jc0oUCp+/1MXGUe0zb0meMnBu2f3e/h5Lxkd2z4lPPdxejpNaFc2H1\nuC+56ZJxbKlu73UPsTYh\n=gQKI\n-----END PGP SIGNATURE-----\n\n--===============0594182808971957567==--'''
raw = base64.urlsafe_b64encode(message_as_str)
gmail_service.users().messages().send(userId='me', body={'raw':raw}).execute()
我在sendbox中的内容是:
Received: from 333313917298-rr7th7jvf4alej59jkv5bbs2fl8sc0j9.apps.googleusercontent.com
named unknown
by gmailapi.google.com
with HTTPREST;
Wed, 12 Nov 2014 03:23:50 -0800
Content-Type: multipart/signed; protocol="application/pgp-signature";
micalg="pgp-sha512"; boundary="===============0594182808971957567=="
MIME-Version: 1.0
Date: Wed, 12 Nov 2014 03:23:50 -0800
Subject: A test email
From: Leo Iannacone <l3on@ubuntu.com>
To: Andrea Colangelo <warp10@ubuntu.com>
Message-Id: <CACzqv1fvmbg2Er0Fi-poFSfEDaCLXxW-WGQr8dwHma6t9NjBzA@mail.gmail.com>
--===============0594182808971957567==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Hello,
this is a signed email (RFC 3156).
Best,
L.
-- =
Ubuntu Member - http://launchpad.net/~l3on
Home Page - http://leoiannacone.com
GPG Key Id - 0xD282FC25
--===============0594182808971957567==
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: GooPG digital signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABCgAGBQJUY0JcAAoJEDMrlP7SgvwlQakP/jmw6OOcafFAxMnMZNBREnG6
GF3cG/ACJ6BeYhOb0Q2HFQrUKACbsB8QaTxSCf3q7O0HIl5Atr9IVmVIoUuHOM9M
Zt66LWQ3ZUpvyulBswYOq4ERkeeAZh8AYHCz81SUWt42PDn+RrrKESifkgOgy1cM
UpNUXX99cppdY3w1oKVS0SFdhT4ZDNSr6PVUzPzWOHNk3OGOg4okTJOag3lp5R1x
IMQ4plOFNNUs1bDDOpH75TOOGIAdqqgInH5fOk8h2djrPyCozhyllrpCJdiCkrj9
jkL/m0nNS/wHW/pnqSPHZuMDrEYCiiI4fqJYZUkiXQu/koDt40TUqAdeEy1HWJS2
pPqqXjjiZ1jlQ2IBbOG8YfgsLmexTyNE6CmPBXiVk6zY2hnhA6sjq/I9qF8F73SS
FALfkbdRddN7NMzjFVES3eV2gfrUrQnxru2G8urUeeQ2POQrxsGQvb5CrK7VMaUx
teB9UruIpPLNUYR0E7Cr17lqlMR5ILdSlx5xFxIIjg3pfItHQXoOfyusoO1xt8XK
tY8oateT4dgwfR2qrguAnZ96vXtI1soqy8P1TLrJAI/d95kIw4PMzWVm1GjyUiRe
gPhYqvGQV6jc0oUCp+/1MXGUe0zb0meMnBu2f3e/h5Lxkd2z4lPPdxejpNaFc2H1
uC+56ZJxbKlu73UPsTYh
=gQKI
-----END PGP SIGNATURE-----
--===============0594182808971957567==--
我的接收者得到的是:
Delivered-To: andrea.colangelo@gmail.com
Received: by 10.70.104.40 with SMTP id gb8csp207478pdb;
Wed, 12 Nov 2014 03:23:54 -0800 (PST)
X-Received: by 10.194.94.132 with SMTP id dc4mr64238431wjb.56.1415791433615;
Wed, 12 Nov 2014 03:23:53 -0800 (PST)
Return-Path: <leo.iannacone@gmail.com>
Received: from fiordland.canonical.com (fiordland.canonical.com. [91.189.94.145])
by mx.google.com with ESMTP id 16si39684910wjr.38.2014.11.12.03.23.53
for <andrea.colangelo@gmail.com>;
Wed, 12 Nov 2014 03:23:53 -0800 (PST)
Received-SPF: softfail (google.com: domain of transitioning leo.iannacone@gmail.com does not designate 91.189.94.145 as permitted sender) client-ip=91.189.94.145;
Authentication-Results: mx.google.com;
spf=softfail (google.com: domain of transitioning leo.iannacone@gmail.com does not designate 91.189.94.145 as permitted sender) smtp.mail=leo.iannacone@gmail.com
Received: from mail-ig0-f170.google.com (mail-ig0-f170.google.com [209.85.213.170])
by fiordland.canonical.com (Postfix) with ESMTPS id ABACCA183B1
for <warp10@ubuntu.com>; Wed, 12 Nov 2014 11:23:52 +0000 (UTC)
Received: by mail-ig0-f170.google.com with SMTP id a13so1193944igq.5
for <warp10@ubuntu.com>; Wed, 12 Nov 2014 03:23:51 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20130820;
h=mime-version:from:date:message-id:subject:to:content-type;
bh=W/iDzPadzt4k3bMV8jLK7/5iZLI23kjqCuGNPJ0hdzY=;
b=MFCFT42IlWfQzbXCCG5slCE4vzpsZg2WQpkmwFa7L46b61Yd/zQ522GgPA1rRhsSrP
pHhuhPUfCy6HjZRIFf8GqgtTPhinLiuli+ClOz6Oe9rvjH2JK5ILxf0+17woL1n48QAW
xHnJfo8A/qhBvN42AfdSNVhvcQqQObZ25wBe08zwDJeEWT2XRRiDXcWdWagyqisTronc
kj3CwRj5AOBThEpzA+wPC0Aalofqqu+YMIMuchBoTsfh437BxkHJLg+il6kDobJXVtXB
9OPc8o2JqtWwnzHEkC6QKFG54ddoPwvuyq6S325zuDfuKoVrLGeC/kzWRQP+SudBTw0J
RWBA==
X-Received: by 10.107.135.146 with SMTP id r18mr1699637ioi.62.1415791431765;
Wed, 12 Nov 2014 03:23:51 -0800 (PST)
Received: from 333313917298-rr7th7jvf4alej59jkv5bbs2fl8sc0j9.apps.googleusercontent.com
named unknown by gmailapi.google.com with HTTPREST; Wed, 12 Nov 2014 03:23:50 -0800
MIME-Version: 1.0
From: Leo Iannacone <l3on@ubuntu.com>
Date: Wed, 12 Nov 2014 03:23:50 -0800
Message-ID: <CACzqv1fvmbg2Er0Fi-poFSfEDaCLXxW-WGQr8dwHma6t9NjBzA@mail.gmail.com>
Subject: A test email
To: Andrea Colangelo <warp10@ubuntu.com>
Content-Type: multipart/mixed; boundary=001a113f96625df1a80507a7a1d8
--001a113f96625df1a80507a7a1d8
Content-Type: text/plain; charset=ISO-8859-1
Hello,
this is a signed email (RFC 3156).
Best,
L.
--
Ubuntu Member - http://launchpad.net/~l3on
Home Page - http://leoiannacone.com
GPG Key Id - 0xD282FC25
--001a113f96625df1a80507a7a1d8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Disposition: attachment; filename="signature.asc"
Content-Transfer-Encoding: base64
X-Attachment-Id: bc758a9561fcd7dc_0.1
LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcgdjEKCmlRSWNCQUFC
Q2dBR0JRSlVZMEpjQUFvSkVETXJsUDdTZ3Z3bFFha1Avam13Nk9PY2FmRkF4TW5NWk5CUkVuRzYK
R0YzY0cvQUNKNkJlWWhPYjBRMkhGUXJVS0FDYnNCOFFhVHhTQ2YzcTdPMEhJbDVBdHI5SVZtVklv
VXVIT005TQpadDY2TFdRM1pVcHZ5dWxCc3dZT3E0RVJrZWVBWmg4QVlIQ3o4MVNVV3Q0MlBEbitS
cnJLRVNpZmtnT2d5MWNNClVwTlVYWDk5Y3BwZFkzdzFvS1ZTMFNGZGhUNFpETlNyNlBWVXpQeldP
SE5rM09HT2c0b2tUSk9hZzNscDVSMXgKSU1RNHBsT0ZOTlVzMWJERE9wSDc1VE9PR0lBZHFxZ0lu
SDVmT2s4aDJkanJQeUNvemh5bGxycENKZGlDa3JqOQpqa0wvbTBuTlMvd0hXL3BucVNQSFp1TURy
RVlDaWlJNGZxSllaVWtpWFF1L2tvRHQ0MFRVcUFkZUV5MUhXSlMyCnBQcXFYamppWjFqbFEySUJi
T0c4WWZnc0xtZXhUeU5FNkNtUEJYaVZrNnpZMmhuaEE2c2pxL0k5cUY4RjczU1MKRkFMZmtiZFJk
ZE43Tk16akZWRVMzZVYyZ2ZyVXJRbnhydTJHOHVyVWVlUTJQT1FyeHNHUXZiNUNySzdWTWFVeAp0
ZUI5VXJ1SXBQTE5VWVIwRTdDcjE3bHFsTVI1SUxkU2x4NXhGeElJamczcGZJdEhRWG9PZnl1c29P
MXh0OFhLCnRZOG9hdGVUNGRnd2ZSMnFyZ3VBblo5NnZYdEkxc29xeThQMVRMckpBSS9kOTVrSXc0
UE16V1ZtMUdqeVVpUmUKZ1BoWXF2R1FWNmpjMG9VQ3ArLzFNWEdVZTB6YjBtZU1uQnUyZjNlL2g1
THhrZDJ6NGxQUGR4ZWpwTmFGYzJIMQp1Qys1NlpKeGJLbHU3M1VQc1RZaAo9Z1FLSQotLS0tLUVO
RCBQR1AgU0lHTkFUVVJFLS0tLS0K
--001a113f96625df1a80507a7a1d8--
正如您所看到的......内容类型与我发送的邮件中的内容类型不同,以及我收到的收件箱中的内容。
答案 0 :(得分:3)
从我的测试来看,这似乎是Gmail API的一个问题。目前还不清楚API是否计划支持这个用例,但我已经向工程团队提出了这个问题。