Go to the latest version of this document.

# ``twisted`.`mail`.`alias`.`FileWrapper``

class documentation

`class FileWrapper: (source)`

Constructor: `FileWrapper(filename)`

Implements interfaces: `twisted.mail.interfaces.IMessageSMTP`

View In Hierarchy

A message receiver which delivers a message to a file.

Method | `__init__` | No summary
Method | `__str__` | Build a string representation of this `FileWrapper` instance.
Method | `connectionLost` | Close the temporary file when the connection is lost.
Method | `eomReceived` | Handle end of message by writing the message to the file.
Method | `lineReceived` | Write a received line to the temporary file.
Instance Variable | `finalname` | The name of the file in which the message should be stored.
Instance Variable | `fp` | A file used for temporary storage of the message.

def __init__(self, filename): (source)

Parameters
filename:`bytes` | The name of the file in which the message should be stored.

def __str__(self) -> `str`: (source)

Build a string representation of this `FileWrapper` instance.

Returns
`bytes` | A string containing the file name of the message.

def connectionLost(self): (source)
from `twisted.mail.interfaces.IMessageSMTP`

Close the temporary file when the connection is lost.

def eomReceived(self): (source)
from `twisted.mail.interfaces.IMessageSMTP`

Handle end of message by writing the message to the file.

Returns
`Deferred` which successfully results in `bytes` | A deferred which succeeds with the name of the file to which the message has been stored or fails if the message cannot be saved to the file.

def lineReceived(self, line): (source)
from `twisted.mail.interfaces.IMessageSMTP`

Write a received line to the temporary file.

Parameters
line:`bytes` | A received line of the message.

finalname: `bytes` = (source)

The name of the file in which the message should be stored.

fp: file-like object = (source)

A file used for temporary storage of the message.