Gmail responds with "Not valid RFC 5321 address" error for RCPT but not MAIL verb
<p>In the context of writing an MSA (of sorts) for our application I'm currently writing some code to test if it is possible to connect to a given address to send mail, including if authentication is required.</p>

<p>To test for the latter I pretend to be sending an email from the (fictional)  address with the same address used for the recipient.</p>

<p>I use this approach,  although I'd rather not have to, since I need to be able to send both a MAIL verb and an RCPT verb to the server. The reason for this is, as far as I can tell, no verb prior to sending MAIL (i.e. EHLO, STARTTLS, AUTH etc.) will elicit an error if authentication is missing. Some servers, such as Gmail, respond with an error on sending an unauthorized MAIL, but others only react once I try to add a recipient, hence the need for both verbs.</p>

<p>The reason I use an IP address instead of a domain name in the fictional mail is that I do not necessarily have access to a domain name at that point. I know it isn't pretty, but it is legal. Provided the IP address is specified according to RFC 5321.</p>

<p>The funny thing is that Gmail will accept the MAIL verb using the fictional mail address, but will throw a 553 error when the same address is used for the recipient complaining it isn't a valid RFC 5321 address.</p>

<pre><code>SEND: "MAIL FROM:&lt;test@[IPv6:fe80::105e:c040:c56c:b8bc]&gt;"
RECV: "250 2.1.0 OK s82sm4688131lja.26 - gsmtp"
SEND: "RCPT TO:&lt;test@[IPv6:fe80::105e:c040:c56c:b8bc]&gt;"
RECV: "553-5.1.2 The recipient address &lt;test@[ipv6:fe80::105e:c040:c56c:b8bc]&gt; is not a"
      "553 5.1.2 valid RFC-5321 address. s82sm4688131lja.26 - gsmtp"
</code></pre>

<p>I should note that I've tried this both with and without the IPv6 prefix. Without it, another SMTP server running on Postfix complains. The Postfix-based server is coincidentally one of those not throwing an error when sending the MAIL verb unauthenticated.</p>

<p>This issue with Gmail isn't limited to IPv6 addresses, by the way. Switching to an IPv4 address produces the same result. Neither does the issue seem to be linked to local addresses. The MAIL verb is accepted, the RCPT verb fails.</p>

<p>As far as I can tell what I provide is a proper  RFC 5321 compliant address. What's going on? Where do I go wrong? At first glance the problem seems to be with GMail/GSMTP.</p>