mirror of
https://github.com/postalserver/postal.git
synced 2026-10-18 18:26:06 +00:00
refactor: refactor the SMTP sender
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SMTPClient
|
||||
class Server
|
||||
|
||||
attr_reader :hostname
|
||||
attr_reader :port
|
||||
attr_accessor :ssl_mode
|
||||
|
||||
def initialize(hostname, port: 25, ssl_mode: SSLModes::AUTO)
|
||||
@hostname = hostname
|
||||
@port = port
|
||||
@ssl_mode = ssl_mode
|
||||
end
|
||||
|
||||
# Return all IP addresses for this server by resolving its hostname.
|
||||
# IPv6 addresses will be returned first.
|
||||
#
|
||||
# @return [Array<SMTPClient::Endpoint>]
|
||||
def endpoints
|
||||
ips = []
|
||||
|
||||
DNSResolver.local.aaaa(@hostname).each do |ip|
|
||||
ips << Endpoint.new(self, ip)
|
||||
end
|
||||
|
||||
DNSResolver.local.a(@hostname).each do |ip|
|
||||
ips << Endpoint.new(self, ip)
|
||||
end
|
||||
|
||||
ips
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user