Django allows sending to a localpart-only email address (without @domain). This is not a valid RFC 822/2822/5322 addr-spec, but is accepted by some SMTP servers for local delivery. Regression for #15042.
(self)
| 1470 | self.assertEqual(message.get("cc"), "cc@xn--4ca9at.com") |
| 1471 | |
| 1472 | def test_localpart_only_address(self): |
| 1473 | """ |
| 1474 | Django allows sending to a localpart-only email address |
| 1475 | (without @domain). This is not a valid RFC 822/2822/5322 addr-spec, but |
| 1476 | is accepted by some SMTP servers for local delivery. |
| 1477 | Regression for #15042. |
| 1478 | """ |
| 1479 | email = EmailMessage(from_email="django", to=["localpartonly"]) |
| 1480 | parsed = message_from_bytes(email.message().as_bytes()) |
| 1481 | self.assertEqual( |
| 1482 | parsed["From"].addresses, (Address(username="django", domain=""),) |
| 1483 | ) |
| 1484 | self.assertEqual( |
| 1485 | parsed["To"].addresses, (Address(username="localpartonly", domain=""),) |
| 1486 | ) |
| 1487 | |
| 1488 | def test_lazy_addresses(self): |
| 1489 | """ |
nothing calls this directly
no test coverage detected