① Configure settings for incoming mail

MailServerConnect["imap.example.com",
MailSettings-><|
"Username"->"joesmith",
"Password"->"********",
"MailFolderName"->"INBOX",
"PortNumber"->Automatic
|>]

② Configure settings for outgoing mail

SetOptions[SendMail,
MailSettings-><|
"Server"->"mail.example.com",
"Username"->"joesmith",
"Password"->Automatic,
"FromAddress"->"joesmith@example.com",
"Signature"->"Thanks,",
"EncryptionProtocol"->"TLS",
"PortNumber"->587
|>]