'Test that a C{MAIL FROM} command issued without first authenticating
when a portal has been configured to disallow anonymous logins is
responded to with the correct error code.'

def test_portalRejectedAnonymousSender(self):

    realm = SingletonRealm(smtp.IMessageDelivery, NotImplementedDelivery())
    portal = Portal(realm, [])
    proto = smtp.SMTP()
    proto.portal = portal
    trans = StringTransport()
    proto.makeConnection(trans)
    proto.dataReceived('HELO    example.com\r\n')
    trans.clear()
    proto.dataReceived('MAIL    FROM:<alice@example.com>\r\n')
    proto.connectionLost(error.ConnectionLost())
    self.assertEqual(trans.value(), '550    Cannot    receive    from    specified    address    <alice@example.com>:    Unauthenticated    senders    not    allowed\r\n')
