mailkit.core.smtp package

Submodules

mailkit.core.smtp.config module

class mailkit.core.smtp.config.SmtpConfig(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, host: str, port: Optional[int] = None, username: str, password: str, use_ssl: bool = True, use_tls: bool = False, timeout: int = 10)[source]

Bases: BaseSettings

host: str
model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'env_file': '~/.mailkit.env', 'env_file_encoding': None, 'env_nested_delimiter': None, 'env_prefix': 'SMTP_', 'extra': 'forbid', 'protected_namespaces': ('model_', 'settings_'), 'secrets_dir': None, 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'host': FieldInfo(annotation=str, required=True), 'password': FieldInfo(annotation=str, required=True), 'port': FieldInfo(annotation=Union[int, NoneType], required=False), 'timeout': FieldInfo(annotation=int, required=False, default=10), 'use_ssl': FieldInfo(annotation=bool, required=False, default=True), 'use_tls': FieldInfo(annotation=bool, required=False, default=False), 'username': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

password: str
port: Optional[int]
save_config(env_file=None)[source]
timeout: int
use_ssl: bool
use_tls: bool
username: str

mailkit.core.smtp.message module

class mailkit.core.smtp.message.Message(from_addr: str, to_addrs: Union[str, List[str]], subject: str, body: str = '', content_type: str = 'plain', charset: str = 'utf-8', cc: Union[str, List[str]] = '', bcc: Union[str, List[str]] = '', attachments: Optional[Union[str, List[str]]] = None)[source]

Bases: MessageField

create_message()[source]

Create and populate the MIME multipart message object.

from_addr: str
property message

Property to access the MIME multipart message object.

subject: str
to_addrs: Union[str, List[str]]
class mailkit.core.smtp.message.MessageField(from_addr: str, to_addrs: Union[str, List[str]], subject: str, body: str = '', content_type: str = 'plain', charset: str = 'utf-8', cc: Union[str, List[str]] = '', bcc: Union[str, List[str]] = '', attachments: Optional[Union[str, List[str]]] = None)[source]

Bases: object

Fields:

attachments: Optional[Union[str, List[str]]] = None
bcc: Union[str, List[str]] = ''
body: str = ''
cc: Union[str, List[str]] = ''
charset: str = 'utf-8'
content_type: str = 'plain'
from_addr: str
subject: str
to_addrs: Union[str, List[str]]

mailkit.core.smtp.sendemail module

class mailkit.core.smtp.sendemail.SendEmail(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, host: str, port: Optional[int] = None, username: str, password: str, use_ssl: bool = True, use_tls: bool = False, timeout: int = 10)[source]

Bases: SmtpConfig

close()[source]
host: str
login()[source]
model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'env_file': '~/.mailkit.env', 'env_file_encoding': None, 'env_nested_delimiter': None, 'env_prefix': 'SMTP_', 'extra': 'forbid', 'protected_namespaces': ('model_', 'settings_'), 'secrets_dir': None, 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'host': FieldInfo(annotation=str, required=True), 'password': FieldInfo(annotation=str, required=True), 'port': FieldInfo(annotation=Union[int, NoneType], required=False), 'timeout': FieldInfo(annotation=int, required=False, default=10), 'use_ssl': FieldInfo(annotation=bool, required=False, default=True), 'use_tls': FieldInfo(annotation=bool, required=False, default=False), 'username': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

model_post_init(__context: Any) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. __context: The context.

password: str
port: Optional[int]
send(to_addrs: Union[str, List[str]], subject: str, body: str = '', content_type: str = 'plain', charset: str = 'utf-8', cc: Union[str, List[str]] = '', bcc: Union[str, List[str]] = '', attachments: Optional[Union[str, List[str]]] = None) None[source]
property smtp
timeout: int
use_ssl: bool
use_tls: bool
username: str
mailkit.core.smtp.sendemail.wrap_message_signature(func)[source]

Module contents