-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1560 from tk0miya/net-smtp
stdlib: Add types for net/smtp
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dependencies: | ||
- name: net-protocol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module Net | ||
# Module mixed in to all SMTP error classes | ||
module SMTPError | ||
attr_reader response: Response | ||
|
||
def initialize: (Response response, ?message: String) -> void | ||
|
||
def message: () -> String? | ||
end | ||
|
||
# Represents an SMTP authentication error. | ||
class SMTPAuthenticationError < ProtoAuthError | ||
include SMTPError | ||
end | ||
|
||
# Represents SMTP error code 4xx, a temporary error. | ||
class SMTPServerBusy < ProtoServerError | ||
include SMTPError | ||
end | ||
|
||
# Represents an SMTP command syntax error (error code 500) | ||
class SMTPSyntaxError < ProtoSyntaxError | ||
include SMTPError | ||
end | ||
|
||
# Represents a fatal SMTP error (error code 5xx, except for 500) | ||
class SMTPFatalError < ProtoFatalError | ||
include SMTPError | ||
end | ||
|
||
# Unexpected reply code returned from server. | ||
class SMTPUnknownError < ProtoUnknownError | ||
include SMTPError | ||
end | ||
|
||
# Command is not supported on server. | ||
class SMTPUnsupportedCommand < ProtocolError | ||
include SMTPError | ||
end | ||
|
||
class SMTP < Protocol | ||
def self.start: (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) -> instance | ||
| [T] (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) { (instance) -> T } -> T | ||
| (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) -> instance | ||
| [T] (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) { (instance) -> T } -> T | ||
|
||
def initialize: (String address, ?Integer port) -> void | ||
def send_message: (_Each[String] mail_src, String from_addr, *String to_addrs) -> void | ||
end | ||
|
||
class Response | ||
end | ||
|
||
class SMTPSession = SMTP | ||
end |