From 4dd9c1bf4091e81906b955cf9eda6a447aad3f24 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 5 Mar 2022 12:36:53 +0100 Subject: [PATCH] Let's get started... --- client.go | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 client.go diff --git a/client.go b/client.go new file mode 100644 index 0000000..a6851f0 --- /dev/null +++ b/client.go @@ -0,0 +1,58 @@ +package mail + +import ( + "context" + "time" +) + +// DefaultPort is the default connection port to the SMTP server +const DefaultPort = 25 + +// DefaultTimeout is the default connection timeout +const DefaultTimeout = time.Second * 30 + +// Client is the SMTP client struct +type Client struct { + h string // Hostname of the target SMTP server to connect to + p int // Port of the SMTP server to connect to + s bool // Use SSL/TLS or not + ctx context.Context // The context for the connection handling +} + +// Option returns a function that can be used for grouping Client options +type Option func(*Client) + +// NewClient returns a new Session client object +func NewClient(o ...Option) Client { + c := Client{ + p: DefaultPort, + } + + // Override defaults with optionally provided Option functions + for _, co := range o { + if co == nil { + continue + } + co(&c) + } + + return c +} + +// WithHost overrides the default connection port +func WithHost(h string) Option { + return func(c *Client) { + c.h = h + } +} + +// WithPort overrides the default connection port +func WithPort(p int) Option { + return func(c *Client) { + c.p = p + } +} + +func (c Client) Dial() { + +}